Skip to content

Commit 54d28e2

Browse files
authored
Update login.html
1 parent 0cf6011 commit 54d28e2

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

git/login.html

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,37 @@
33

44
const code = window.location.toString().replace(/.+code=/, '');
55

6-
try {
7-
8-
// check for cross-origin frame
9-
console.log(window.opener.location.href);
6+
let isMobile = false;
7+
8+
if (navigator.userAgentData
9+
&& navigator.userAgentData.mobile) isMobile = true;
10+
11+
if (navigator.userAgent
12+
&& navigator.userAgent.includes('Mobile')) isMobile = true;
13+
14+
15+
if (!isMobile) {
1016

11-
// post login token to opening window
12-
window.opener.postMessage(code, window.location);
13-
window.close();
17+
try {
18+
19+
// check for cross-origin frame
20+
console.log(window.opener.location.href);
21+
22+
// post login token to opening window
23+
window.opener.postMessage(code, window.location);
24+
window.close();
25+
26+
} catch(e) {
27+
28+
// if cannot access opening window (window is cross-origin)
29+
// redirect to dev version and try posting login token from there
30+
window.location.href = window.location.protocol + '//' + 'dev.' + window.location.host + window.location.pathname + window.location.search;
31+
32+
}
1433

15-
} catch(e) {
34+
} else {
1635

17-
// if cannot access opening window (window is cross-origin)
18-
// redirect to dev version and try posting login token from there
19-
window.location.href = window.location.protocol + '//' + 'dev.' + window.location.host + window.location.pathname + window.location.search;
36+
window.location.href = '/full?gitToken=' + code;
2037

2138
}
2239

0 commit comments

Comments
 (0)