2.0.12 • Published 7 years ago

@javs/auth v2.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Auth

npm (scoped with tag) npm CircleCI Codecov Dependencies

js-standard-style

Authentication module for Nuxt.js

📖 Release Notes

Setup

  • Add @javs/auth dependency using yarn or npm to your project
  • Add @javs/auth and @nuxtjs/axios to modules section of nuxt.config.js
{
  modules: [
    '@javs/auth',

     // ...Axios module should be included AFTER @javs/auth
    '@nuxtjs/axios',
 ],
 auth: {
   /* auth options */
 }
}

Options

token

  • Default: { useToken: false, tokenPrefix: null }

This option configure the setToken method of Axios module in the updateToken action.

Example:

{
  token: {
    useToken: true,
    tokenPrefix: 'JWT'
  }
}

Previous example generate this Authorization header in all future requests:

Authorization: JWT <token>

When the user logout or the token expire the header is remove for all future requests.

fetchUser

  • Default: null

If the option exists it is used to obtain the user object in the api response in fetch action. If is null all response is passed to user object in the state.

fetchToken

  • Default: null

This option is used in fetch action to obtain the token from api response. If is null, the module try to obtain the token from token or id_token property.

redirectLoggedIn

  • Default: '/'

This option is used in no-auth middleware.

redirectNotLoggedIn

  • Default: '/login'

This option is used in auth middleware.

License

MIT License

Copyright (c) Nuxt Community

2.0.12

7 years ago

2.0.11

7 years ago

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.1.2

7 years ago