24
1
Fork 0

enabled accounts on Edge

This commit is contained in:
Danny Coates 2019-02-25 11:44:44 -08:00
parent c6cc5f4ac4
commit cccc1a5383
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
4 changed files with 16 additions and 2 deletions

View File

@ -86,7 +86,7 @@ export default async function getCapabilities() {
}
let account = typeof AUTH_CONFIG !== 'undefined';
try {
account = account && !!localStorage && browserName() !== 'edge';
account = account && !!localStorage;
} catch (e) {
account = false;
}

View File

@ -107,7 +107,19 @@ export default function(state, emitter) {
render();
});
/*
FIXME choo on Edge double-triggers loaded routes
causing 'authenticate' to fire twice which leads to
an error. Until that's fixed we have authLocked to
prevent the second event from causing the error.
Once choo doesn't double-trigger we can remove authLocked.
*/
let authLocked = false;
emitter.on('authenticate', async (code, oauthState) => {
if (authLocked) {
return;
}
authLocked = true;
try {
await state.user.finishLogin(code, oauthState);
await state.user.syncFileList();
@ -116,6 +128,7 @@ export default function(state, emitter) {
emitter.emit('replaceState', '/error');
setTimeout(render);
}
authLocked = false;
});
emitter.on('upload', async () => {

View File

@ -10,7 +10,7 @@ module.exports = function(app = choo()) {
app.route('/legal', body(require('./ui/legal')));
app.route('/error', body(require('./ui/error')));
app.route('/blank', body(require('./ui/blank')));
app.route('/oauth', async function(state, emit) {
app.route('/oauth', function(state, emit) {
emit('authenticate', state.query.code, state.query.state);
});
app.route('*', body(require('./ui/notFound')));

View File

@ -70,6 +70,7 @@ module.exports = function(app) {
app.use(bodyParser.json());
app.use(bodyParser.text());
app.get('/', language, pages.index);
app.get('/error', language, pages.blank);
app.get('/oauth', language, pages.blank);
app.get('/legal', language, pages.legal);
app.get('/app.webmanifest', language, require('./webmanifest'));