Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@nuxtjs/auth
Advanced tools
Authentication module for Nuxt.js
@nuxtjs/auth
dependency using yarn or npm to your project@nuxtjs/auth
and @nuxtjs/axios
to modules
section of nuxt.config.js
{
modules: [
'@nuxtjs/auth',
// ...Axios module should be included AFTER @nuxtjs/auth
'@nuxtjs/axios'
],
// Default Values
auth: {
user: {
endpoint: 'auth/user',
propertyName: 'user',
resetOnFail: true
},
login: {
endpoint: 'auth/login',
},
logout: {
endpoint: 'auth/logout',
method: 'GET',
},
redirect: {
notLoggedIn: '/login',
loggedIn: '/'
},
token: {
enabled: true,
type: 'Bearer',
localStorage: true,
name: 'token',
cookie: true,
cookieName: 'token'
}
}
Sets the global settings for store fetch action.
true
)Set the global settings for store login action.
Sets the global settings for store logout action.
auth
middleware is added to a page.no-auth
middleware is added to a page.// ... code ...
// Do a password based login
store.dispatch('auth/login', {
fields: {
username: 'your_username',
password: 'your_password'
}
})
// ... code ...
store.dispatch('auth/logout') // run logout
// ... code ...
store.state.auth.token // get access token
// ... code ...
store.state.auth.user // get user data
// ... code ...
store.getters['auth/loggedIn'] // get login status (true or false)
// ... in nuxt.config.js ...
router: {
middleware: [
'auth', // If user not logged in, redirect to '/login' or to URL defined in redirect property
'no-auth' // If user is already logged in, redirect to '/' or to URL defined in redirect property
]
}
Copyright (c) Nuxt Community
FAQs
Authentication module for Nuxt.js
The npm package @nuxtjs/auth receives a total of 7,948 weekly downloads. As such, @nuxtjs/auth popularity was classified as popular.
We found that @nuxtjs/auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.