
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@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
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.