From cccc1a5383a05cdeb73c583addbd1cff95d4ecfe Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Mon, 25 Feb 2019 11:44:44 -0800 Subject: [PATCH] enabled accounts on Edge --- app/capabilities.js | 2 +- app/controller.js | 13 +++++++++++++ app/routes.js | 2 +- server/routes/index.js | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/capabilities.js b/app/capabilities.js index f97d34dc..3939fea2 100644 --- a/app/capabilities.js +++ b/app/capabilities.js @@ -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; } diff --git a/app/controller.js b/app/controller.js index 95fa9ad3..9768e274 100644 --- a/app/controller.js +++ b/app/controller.js @@ -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 () => { diff --git a/app/routes.js b/app/routes.js index 8405db9b..54a199a2 100644 --- a/app/routes.js +++ b/app/routes.js @@ -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'))); diff --git a/server/routes/index.js b/server/routes/index.js index 3fd9f045..a43f0395 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -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'));