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 {
2222 this . $state = storage . state
2323 }
2424
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 ( ) {
3526 // Restore strategy
3627 this . $storage . syncUniversal ( 'strategy' , this . options . defaultStrategy )
3728
@@ -46,7 +37,16 @@ export default class Auth {
4637 }
4738
4839 // 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+ }
5050 }
5151
5252 // Backward compatibility
You can’t perform that action at this time.
0 commit comments