diff --git a/docs/api/methods.md b/docs/api/methods.md index b1663ee6b..7c4a3eb77 100644 --- a/docs/api/methods.md +++ b/docs/api/methods.md @@ -2,18 +2,31 @@ > You can all auth methods anywhere that `this` or `context.app` is available using `$auth`. -### `login` +### `loginWith(strategyName, ...args)` - Returns: `Promise` -Login using active strategy. Usage varies by current scheme. +Set current strategy to `strategyName` and try to do login. Usage varies by current strategy. + +```js +this.$auth.loginWith('local', /* .... */) + .then(() => this.$toast.success('Logged In!')) +``` + +### `login(...args)` + +- Returns: `Promise` + +Login using active strategy. Usage varies by current strategy. + +> Using `loginWith` is recommended instead of this function! ```js this.$auth.login(/* .... */) .then(() => this.$toast.success('Logged In!')) ``` -## `logout` +## `logout()` - Returns: `Promise` @@ -23,7 +36,7 @@ Logout active strategy. Usage varies by current scheme. await this.$auth.logout() ``` -## `fetchUser` +## `fetchUser()` - Returns: `Promise` @@ -33,7 +46,7 @@ Force re-fetch user using active strategy. await this.$auth.fetchUser() ``` -## `hasScope` +## `hasScope(scopeName)` Check if user has a specific scope: ```js @@ -41,7 +54,7 @@ Check if user has a specific scope: this.$auth.hasScope('admin') ``` -### `setToken` +### `setToken(token)` Set token in all neccessary places including Vuex, local state, localStorage and Axios headers. @@ -50,7 +63,7 @@ Set token in all neccessary places including Vuex, local state, localStorage and this.$auth.setToken('123') ``` -### `onError` +### `onError(handler)` Listen for auth errors: (`plugins/auth.js`) diff --git a/docs/strategies/auth0.md b/docs/strategies/auth0.md index 5d435abdb..6b2425d0f 100644 --- a/docs/strategies/auth0.md +++ b/docs/strategies/auth0.md @@ -38,7 +38,7 @@ If this option is not provided, URL of login (or page which initiates login) wil To initiate login: ```js -this.$auth.strategies.auth0.login() +this.$auth.loginWith('auth0') ``` User will be redirected to a page like this: diff --git a/docs/strategies/local.md b/docs/strategies/local.md index d63166529..8823b2c70 100644 --- a/docs/strategies/local.md +++ b/docs/strategies/local.md @@ -42,7 +42,7 @@ This option can be used to disable all token handling. Useful for Cookie only fl To do a password based login by sending credentials in request body as a JSON object: ```js -this.$auth.local.login({ +this.$auth.local.loginWith('local', { data: { username: 'your_username', password: 'your_password' diff --git a/examples/demo/pages/login.vue b/examples/demo/pages/login.vue index 56da763e3..d22b2fb79 100644 --- a/examples/demo/pages/login.vue +++ b/examples/demo/pages/login.vue @@ -18,7 +18,7 @@