From d07c8afb338a7493a809de6cbf67f5d08e0106ce Mon Sep 17 00:00:00 2001 From: "wade.wei" Date: Wed, 29 Aug 2018 14:20:29 +0800 Subject: [PATCH 1/2] fix: auth init --- lib/core/auth.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/core/auth.js b/lib/core/auth.js index da2dc6560..6625e5c08 100644 --- a/lib/core/auth.js +++ b/lib/core/auth.js @@ -44,17 +44,21 @@ export default class Auth { return Promise.resolve() } } - - // Call mounted for active strategy on initial load - await this.mounted() - - // Watch for loggedIn changes only in client side - if (process.browser && this.options.watchLoggedIn) { - this.$storage.watchState('loggedIn', loggedIn => { - if (!routeOption(this.ctx.route, 'auth', false)) { - this.redirect(loggedIn ? 'home' : 'logout') - } - }) + + try { + // Call mounted for active strategy on initial load + await this.mounted() + } catch (e) { + + } finally { + // Watch for loggedIn changes only in client side + if (process.browser && this.options.watchLoggedIn) { + this.$storage.watchState('loggedIn', loggedIn => { + if (!routeOption(this.ctx.route, 'auth', false)) { + this.redirect(loggedIn ? 'home' : 'logout') + } + }) + } } } From 2018d199918296d251c4dc98a3b7fcbc272b7a3b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 1 Nov 2018 17:19:30 +0330 Subject: [PATCH 2/2] fixes --- lib/core/auth.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/auth.js b/lib/core/auth.js index 6625e5c08..dba4ce241 100644 --- a/lib/core/auth.js +++ b/lib/core/auth.js @@ -48,11 +48,11 @@ export default class Auth { try { // Call mounted for active strategy on initial load await this.mounted() - } catch (e) { - + } catch (error) { + this.callOnError(error) } finally { // Watch for loggedIn changes only in client side - if (process.browser && this.options.watchLoggedIn) { + if (process.client && this.options.watchLoggedIn) { this.$storage.watchState('loggedIn', loggedIn => { if (!routeOption(this.ctx.route, 'auth', false)) { this.redirect(loggedIn ? 'home' : 'logout')