2
2
3
3
> You can all auth methods anywhere that ` this ` or ` context.app ` is available using ` $auth ` .
4
4
5
- ### ` login `
5
+ ### ` loginWith(strategyName, ...args) `
6
6
7
7
- Returns: ` Promise `
8
8
9
- Login using active strategy. Usage varies by current scheme.
9
+ Set current strategy to ` strategyName ` and try to do login. Usage varies by current strategy.
10
+
11
+ ``` js
12
+ this .$auth .loginWith (' local' , /* .... */ )
13
+ .then (() => this .$toast .success (' Logged In!' ))
14
+ ```
15
+
16
+ ### ` login(...args) `
17
+
18
+ - Returns: ` Promise `
19
+
20
+ Login using active strategy. Usage varies by current strategy.
21
+
22
+ > Using ` loginWith ` is recommended instead of this function!
10
23
11
24
``` js
12
25
this .$auth .login (/* .... */ )
13
26
.then (() => this .$toast .success (' Logged In!' ))
14
27
```
15
28
16
- ## ` logout `
29
+ ## ` logout() `
17
30
18
31
- Returns: ` Promise `
19
32
@@ -23,7 +36,7 @@ Logout active strategy. Usage varies by current scheme.
23
36
await this .$auth .logout ()
24
37
```
25
38
26
- ## ` fetchUser `
39
+ ## ` fetchUser() `
27
40
28
41
- Returns: ` Promise `
29
42
@@ -33,15 +46,15 @@ Force re-fetch user using active strategy.
33
46
await this .$auth .fetchUser ()
34
47
```
35
48
36
- ## ` hasScope `
49
+ ## ` hasScope(scopeName) `
37
50
Check if user has a specific scope:
38
51
39
52
``` js
40
53
// Returns is a computed boolean
41
54
this .$auth .hasScope (' admin' )
42
55
```
43
56
44
- ### ` setToken `
57
+ ### ` setToken(token) `
45
58
46
59
Set token in all neccessary places including Vuex, local state, localStorage and Axios headers.
47
60
@@ -50,7 +63,7 @@ Set token in all neccessary places including Vuex, local state, localStorage and
50
63
this .$auth .setToken (' 123' )
51
64
```
52
65
53
- ### ` onError `
66
+ ### ` onError(handler) `
54
67
55
68
Listen for auth errors: (` plugins/auth.js ` )
56
69
0 commit comments