- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用 Nuxt.js 及其附带的身份验证模块。
是否可以在身份验证中创建豁免,以防止用户未登录时自动重定向到登录页面?
以下为例:
用户未登录并导航至:http://localhost:3000/#/password-reset
他们将被重定向到登录屏幕:http://localhost:3000/#/login
我想创建一个豁免,以便所有路由都受到身份验证的保护,它们已经受到保护,但重置密码的页面 ( http://localhost:3000/#/password-reset ) 除外。
这怎么可能?
最佳答案
我假设您正在使用 nuxt-auth .
创建中间件middleware/isAuth.js
:
export default function({ app, error }) {
if (!app.$auth.loggedIn) {
// If you want to redirect to login page
app.router.push('/password-reset')
// If you want to throw error, use this:
return error({
statusCode: 403,
message: 'You are not allowed to see this'
})
}
}
在您想要保护的页面中,声明您的中间件:
export default {
...
middleware: ['isAuth'],
...
}
如果用户未登录,它将阻止页面。要登录用户,您应该使用 loginWith
.
关于javascript - NuxtJS 和 Auth 路由豁免,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58836600/
整个分析的新手,我发现这非常困惑 我想在我的 nuxt ssr webapp 中使用 Google Analytics 4,但我对众多选项感到不知所措 Quick issue on nuxtjs/go
图像文件是否必须保存在nuxtProject的静态文件夹中?相反,它将使用 axios 保存在后端服务器中。抱歉,我无法提供示例代码,因为我对此一无所知。计划是将保存在静态文件夹中并将前端 url 发
我认为这方面有很多问题。但是没有正确答案。如何查看生产模式错误日志的详细信息? 最佳答案 Nuxt 在 nuxt.config.js 文件中提供了一个标志来启用生产调试 { debug: true
我正在使用我在下面添加的部署脚本部署我的 NuxtJS 应用程序。我使用了本教程中的一些说明:https://www.digitalocean.com/community/tutorials/how-
大家好! 我面临着一个我找不到解决方法的大问题。 简而言之 - 我希望能够生成以前未知长度的多级路由来创建过滤器。 更多详情有一个网站site.com 它有部分:site.com/news、site.
我将我应该在我的 Nuxt 应用程序中使用的模板的所有文件(css、js、图像等。)添加到 assets/theme 文件夹中。有 assets 文件夹结构: 在 assets/theme/sass/
好吧,我从 nuxt 开始,我有以下路线: /home /dashboard /login 我想保护 /dashboard,但仅限于使用 Cookie 中的 token 登录的用户。 然后我创建了一个
调用 $auth.loginWith('google') 后,我得到 http://localhost:3000/ru/user-registration#state=D7xooLsNNxNGfbvc
我有一个网站,比如说 example.com它与子域 blog.example.com 共享布局和少量组件所以我想为此创建通用的nuxtJS项目,以便nuxtJS优化路由和所有东西,我不想为此创建2个
基本上我需要将脚本添加到我的 index.html 的头部, 所以我试过的是...... 在我的 nuxt.config.js 中 head: { script: [ {
我在 Nuxt 项目中使用 vuetify 时遇到问题,我按照文档说明您只需将 @nuxtjs/vuetify 依赖项安装到您的项目中,并在 中添加一行nuxt.config.js 文件的 >buil
我正在使用 NuxtJs auth module处理我在州内的授权。对于身份验证,我写了一个有效的 express api。 我的 nuxt.config.js 中有以下配置: axios: {
我最近使用js的moment函数来vue。 但它不起作用。 这是说那个时刻没有定义。 我在这里寻找解决方案,但其中任何一个都不适合我。 如何在 nuxt 中使用时刻? import moment f
我是 Vue 和 NuxtJs 的新手。我正在尝试使用 NuxtJs 构建网络摄像头,但遇到了一些问题 Take Photo
我正在使用 NuxtJS 的 AsyncData 方法从 API 获取视频文件,然后作为文件对象返回到页面。 像这样: async AsyncData({$axios}){ var user_
无法使用 nuxt-community 的 Firebase 模块链接从 Firebase 实时数据库读取/检索数据 here 。已经在 nuxt.config.js 文件中添加了我的 firebas
我的 NuxtJS 应用程序中有一个接受查询参数的路由。我正在尝试实现一种允许用户更改查询参数并重新加载页面的逻辑。 我试过: // this does not work because I'm al
我的 NuxtJS 应用程序中有一个接受查询参数的路由。我正在尝试实现一种允许用户更改查询参数并重新加载页面的逻辑。 我试过: // this does not work because I'm al
在服务器渲染代理工作正常。请求将发送至 custom-server.com/v1/places。但在浏览器中请求将转到 current-domain.com/api/places 为什么它在浏览器中不
当我尝试在 nuxtjs 中获取一些数据时显示此错误 Cannot read property '_normalized' of undefined 这是我在 nuxtjs 中的 axios 请求:
我是一名优秀的程序员,十分优秀!