最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

NestJSNodeJSPassportJWT

网站源码admin30浏览0评论

NestJS / NodeJS / Passport / JWT

NestJS / NodeJS / Passport / JWT

我有一个由JWT保护的NestJS后端。我想知道什么是存储实际用户的最佳方法或将其传递给我的服务的最佳方法?

我有一个JwtAuthGuard

@Injectable()
export class JwtAuthGuard extends AuthGuard( 'jwt' ) {
  canActivate(context: ExecutionContext) {
    return super.canActivate( context );
  }

  handleRequest(err, user, info) {
    if ( err || !user ) {
      throw err || new UnauthorizedException();
    }
    return user;
  }
}

我的实际用户ID在handleRequest中的var用户中,但是我不知道在哪里可以“存储”它,以便在某些模块中可以访问它。有人可以帮助我吗?

谢谢

回答如下:

check the answer of this question

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论