Skip to content

Commit 03dba23

Browse files
gotoinpi0
authored andcommitted
fix(auth): handle mounted errors during init (#234)
1 parent eb7dc9e commit 03dba23

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/core/auth.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,21 @@ export default class Auth {
4444
return Promise.resolve()
4545
}
4646
}
47-
48-
// Call mounted for active strategy on initial load
49-
await this.mounted()
50-
51-
// Watch for loggedIn changes only in client side
52-
if (process.browser && this.options.watchLoggedIn) {
53-
this.$storage.watchState('loggedIn', loggedIn => {
54-
if (!routeOption(this.ctx.route, 'auth', false)) {
55-
this.redirect(loggedIn ? 'home' : 'logout')
56-
}
57-
})
47+
48+
try {
49+
// Call mounted for active strategy on initial load
50+
await this.mounted()
51+
} catch (error) {
52+
this.callOnError(error)
53+
} finally {
54+
// Watch for loggedIn changes only in client side
55+
if (process.client && this.options.watchLoggedIn) {
56+
this.$storage.watchState('loggedIn', loggedIn => {
57+
if (!routeOption(this.ctx.route, 'auth', false)) {
58+
this.redirect(loggedIn ? 'home' : 'logout')
59+
}
60+
})
61+
}
5862
}
5963
}
6064

0 commit comments

Comments
 (0)