Skip to content
4 changes: 2 additions & 2 deletions filebrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async function renderSidebarHTML() {
resp = await git.getItems(treeLoc);


if (resp.message == 'Not Found') {
if (resp.message && resp.message == 'Not Found') {

// if couldn't find repository, show not found screen

Expand Down Expand Up @@ -323,7 +323,7 @@ async function renderSidebarHTML() {

}

if (resp.message == 'Bad credentials') {
if (resp.message && resp.message == 'Bad credentials') {

// if failed to get items,
// show login screen
Expand Down
44 changes: 41 additions & 3 deletions git/gitauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ window.onload = async () => {


loginButton.addEventListener('click', () => {

window.open('https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org', 'Login with Github', 'height=575,width=575');

if (isMobile) {

window.location.href = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';

} else {

window.open('https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org', 'Login with Github', 'height=575,width=575');

}

})

Expand Down Expand Up @@ -101,9 +109,39 @@ window.onload = async () => {
}

})


loadLS();


// if git code exists in link
if (linkData.gitCode) {

// hide intro screen
sidebar.classList.remove('intro');

// if on safari, refresh header color
if (isSafari) {

loadLS();
document.querySelector('meta[name="theme-color"]').content = '#313744';

onNextFrame(() => {

document.querySelector('meta[name="theme-color"]').content = '#1a1c24';

});

}

// start loading
startLoading();

const gitCode = linkData.gitCode;

// get git token from Github
getGithubToken(gitCode);

}

}

Expand Down
39 changes: 28 additions & 11 deletions git/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,37 @@

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

try {

// check for cross-origin frame
console.log(window.opener.location.href);
let isMobile = false;

if (navigator.userAgentData
&& navigator.userAgentData.mobile) isMobile = true;

if (navigator.userAgent
&& navigator.userAgent.includes('Mobile')) isMobile = true;


if (!isMobile) {

// post login token to opening window
window.opener.postMessage(code, window.location);
window.close();
try {

// check for cross-origin frame
console.log(window.opener.location.href);

// post login token to opening window
window.opener.postMessage(code, window.location);
window.close();

} catch(e) {

// if cannot access opening window (window is cross-origin)
// redirect to dev version and try posting login token from there
window.location.href = window.location.protocol + '//' + 'dev.' + window.location.host + window.location.pathname + window.location.search;

}

} catch(e) {
} else {

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

}

Expand Down
6 changes: 6 additions & 0 deletions links.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ function decodeLink(url) {

}

if (link.get('gitCode')) {

linkData.gitCode = link.get('gitCode');

}



// legacy link type
Expand Down
2 changes: 1 addition & 1 deletion worker/client-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


// update worker name when updating worker
const WORKER_NAME = 'codeit-worker-v525';
const WORKER_NAME = 'codeit-worker-v526';


// internal paths
Expand Down