node.js - 使用全球 AuthGuard 自定义护照策略
问题描述
我已经按照该页面https://docs.nestjs.com/techniques/authentication中的描述实现了 JWT 身份验证
当我@UseGuard
为特定控制器使用装饰器时,它可以正常工作。但是,如果我将其设置为main.ts
using useGlobalGuards
,则不使用我的策略,并且可能使用默认策略。
app.useGlobalGuards(new (AuthGuard('jwt')));
我究竟做错了什么?
解决方案
推荐阅读
- python - 在具有行索引的模式之后插入新字符串并写入新文件
- android - 构建 android 应用程序的问题,LeftShift 错误
- grammar - 如何将带有量词的模棱两可的语法转换为 LL1?
- r - 使用 rvest 从搜索中获取 URL
- forms - 如何将 GTM 事件添加到此表单完成时触发的回调?
- sas - 对于数百个变量,如何根据变量中的最大值重新编码变量的值?
- python - 如何使用 LED、按钮命令和时序进行适当的反应时间模拟
- excel - 如果前三个字符中包含“SEP”或“SIP”,如何查找并突出显示字符串?
- javascript - 如何故意冻结浏览器窗口(如警报、确认和提示)?
- bash - 插入文本字符串