Closed chenyuncai closed 2 years ago
Passport 登录后用户信息反序列化函数里,依赖注入的数据库操作对象为空
您好,按照文档尝试集成passport做用户登录时,
@CustomStrategy() export class LocalStrategy extends PassportStrategy(Strategy) { @InjectEntityModel(UserEntity) userModel: Repository<UserEntity>; async validate(username: string, password) {} serializeUser(user: UserEntity, done) {} async deserializeUser(username: string, done) {} }
在validate函数中可以正常使用this.userModel进行数据库查询,但在deserializeUser里userModel为undedined。不能调用其下的数据库查询方法,validate与deserializeUser函数的执行机制有什么区别吗?
可能 this 丢了。。
是的,反序列化里打印this,this为undefined
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Passport 登录后用户信息反序列化函数里,依赖注入的数据库操作对象为空
您好,按照文档尝试集成passport做用户登录时,
在validate函数中可以正常使用this.userModel进行数据库查询,但在deserializeUser里userModel为undedined。不能调用其下的数据库查询方法,validate与deserializeUser函数的执行机制有什么区别吗?