情况:
捕获错误的护照库函数的代码:
return function authenticate(req, res, next) {
req.login =
req.logIn = req.logIn || IncomingMessageExt.logIn;
req.logout =
req.logOut = req.logOut || IncomingMessageExt.logOut;
req.isAuthenticated = req.isAuthenticated || IncomingMessageExt.isAuthenticated;
req.isUnauthenticated = req.isUnauthenticated || IncomingMessageExt.isUnauthenticated;
req._sessionManager = passport._sm;
..............
存储库链接:https://github.com/Gleb-Gaiduk/artwine-api https://github.com/Gleb-Gaiduk/artwine-api关于克隆工作存储库后可能出现什么问题有什么想法吗?
您需要将 ExecutionContext 从 Graphql 转换为 Nestjs/Passport 可以读取的:https://docs.nestjs.com/graphql/other-features#execution-context https://docs.nestjs.com/graphql/other-features#execution-context
import { ExecutionContext, Injectable } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
export class MySuperGuard extends AuthGuard('jwt') {
getRequest(context: ExecutionContext) {
const ctx = GqlExecutionContext.create(context);
return ctx.getContext().req;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)