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') + } + }) + } } }