@@ -39,8 +39,7 @@ this.$auth.loggedIn
39
39
this .$store .state .auth .loggedIn
40
40
```
41
41
42
- Under the hood, auth uses attached [ ` $storage ` ] ( ./storage.md ) instance to provide this states.
43
-
42
+ Under the hood, auth uses attached [ ` $storage ` ] ( ./storage ) instance to provide this states.
44
43
45
44
## methods
46
45
@@ -51,10 +50,20 @@ Under the hood, auth uses attached [`$storage`](./storage.md) instance to provid
51
50
Set current strategy to ` strategyName ` and attempt login. Usage varies by current strategy.
52
51
53
52
``` js
54
- this .$auth .loginWith (' local' , { data: { /* data to post to server */ } })
53
+ this .$auth
54
+ .loginWith (' local' , {
55
+ data: {
56
+ /* data to post to server */
57
+ }
58
+ })
55
59
.then (() => this .$toast .success (' Logged In!' ))
56
-
57
- this .$auth .loginWith (' google' , { params: { /* additional authentication parameters */ } })
60
+
61
+ this .$auth
62
+ .loginWith (' google' , {
63
+ params: {
64
+ /* additional authentication parameters */
65
+ }
66
+ })
58
67
.then (() => this .$toast .success (' Logged In!' ))
59
68
```
60
69
@@ -67,8 +76,7 @@ Login using active strategy. Usage varies by current strategy.
67
76
> ** TIP:** Using ` loginWith ` is recommended instead of this function!
68
77
69
78
``` js
70
- this .$auth .login (/* .... */ )
71
- .then (() => this .$toast .success (' Logged In!' ))
79
+ this .$auth .login (/* .... */ ).then (() => this .$toast .success (' Logged In!' ))
72
80
```
73
81
74
82
### ` setUser(user) `
@@ -90,7 +98,8 @@ Set the auth token and optionally the refresh token, then it will fetch the user
90
98
> ** TIP:** This function can properly set the user after registration
91
99
92
100
``` js
93
- this .$auth .setUserToken (token, refreshToken)
101
+ this .$auth
102
+ .setUserToken (token, refreshToken)
94
103
.then (() => this .$toast .success (' User set!' ))
95
104
```
96
105
@@ -125,7 +134,7 @@ this.$auth.hasScope('admin')
125
134
126
135
### ` refreshTokens() `
127
136
128
- Refreshes tokens if * refresh token * is available and not expired. This only works when logged in.
137
+ Refreshes tokens if _ refresh token _ is available and not expired. This only works when logged in.
129
138
130
139
``` js
131
140
// Refresh tokens
@@ -139,7 +148,7 @@ this.$auth.refreshTokens()
139
148
Listen for auth errors: (` plugins/auth.js ` )
140
149
141
150
``` js
142
- export default function ({ $auth }) {
151
+ export default function ({ $auth }) {
143
152
$auth .onError ((error , name , endpoint ) => {
144
153
console .error (name, error)
145
154
})
@@ -148,10 +157,10 @@ export default function({ $auth }) {
148
157
149
158
### ` onRedirect(handler) `
150
159
151
- Pre-process URLs before redirect: (` plugins/auth.js ` )
160
+ Pre-process URLs before redirect: (` plugins/auth.js ` )
152
161
153
- ``` js
154
- export default function ({ $auth }) {
162
+ ``` js
163
+ export default function ({ $auth }) {
155
164
$auth .onRedirect ((to , from ) => {
156
165
console .error (to)
157
166
// you can optionally change `to` by returning a new value
0 commit comments