22
33> You can all auth methods anywhere that ` this ` or ` context.app ` is available using ` $auth ` .
44
5- ### ` login `
5+ ### ` loginWith(strategyName, ...args) `
66
77- Returns: ` Promise `
88
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!
1023
1124``` js
1225this .$auth .login (/* .... */ )
1326 .then (() => this .$toast .success (' Logged In!' ))
1427```
1528
16- ## ` logout `
29+ ## ` logout() `
1730
1831- Returns: ` Promise `
1932
@@ -23,7 +36,7 @@ Logout active strategy. Usage varies by current scheme.
2336await this .$auth .logout ()
2437```
2538
26- ## ` fetchUser `
39+ ## ` fetchUser() `
2740
2841- Returns: ` Promise `
2942
@@ -33,15 +46,15 @@ Force re-fetch user using active strategy.
3346await this .$auth .fetchUser ()
3447```
3548
36- ## ` hasScope `
49+ ## ` hasScope(scopeName) `
3750Check if user has a specific scope:
3851
3952``` js
4053// Returns is a computed boolean
4154this .$auth .hasScope (' admin' )
4255```
4356
44- ### ` setToken `
57+ ### ` setToken(token) `
4558
4659Set token in all neccessary places including Vuex, local state, localStorage and Axios headers.
4760
@@ -50,7 +63,7 @@ Set token in all neccessary places including Vuex, local state, localStorage and
5063this .$auth .setToken (' 123' )
5164```
5265
53- ### ` onError `
66+ ### ` onError(handler) `
5467
5568Listen for auth errors: (` plugins/auth.js ` )
5669
0 commit comments