File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,7 @@ export default class Auth {
22
22
this . $state = storage . state
23
23
}
24
24
25
- init ( ) {
26
- // Watch for loggedIn changes only in client side
27
- if ( process . browser ) {
28
- this . $storage . watchState ( 'loggedIn' , loggedIn => {
29
- if ( ! routeOption ( this . ctx . route , 'auth' , false ) ) {
30
- this . redirect ( loggedIn ? 'home' : 'logout' )
31
- }
32
- } )
33
- }
34
-
25
+ async init ( ) {
35
26
// Restore strategy
36
27
this . $storage . syncUniversal ( 'strategy' , this . options . defaultStrategy )
37
28
@@ -46,7 +37,16 @@ export default class Auth {
46
37
}
47
38
48
39
// Call mounted for active strategy on initial load
49
- return this . mounted ( )
40
+ await this . mounted ( )
41
+
42
+ // Watch for loggedIn changes only in client side
43
+ if ( process . browser ) {
44
+ this . $storage . watchState ( 'loggedIn' , loggedIn => {
45
+ if ( ! routeOption ( this . ctx . route , 'auth' , false ) ) {
46
+ this . redirect ( loggedIn ? 'home' : 'logout' )
47
+ }
48
+ } )
49
+ }
50
50
}
51
51
52
52
// Backward compatibility
You can’t perform that action at this time.
0 commit comments