Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 多个本地策略在PassportStrategy中不起作用_Typescript_Nestjs_Nestjs Passport - Fatal编程技术网

Typescript 多个本地策略在PassportStrategy中不起作用

Typescript 多个本地策略在PassportStrategy中不起作用,typescript,nestjs,nestjs-passport,Typescript,Nestjs,Nestjs Passport,我正在使用NestJS框架。我有一个LocalStrategy来验证用户。现在我需要另一个名为MylocalStrategy的本地策略。为此,我添加了两个文件:mylocal.strategy.ts和mylocal-auth.guard.ts 这是我的mylocal auth.guard.ts内容: import { Injectable } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; @Inject

我正在使用NestJS框架。我有一个
LocalStrategy
来验证用户。现在我需要另一个名为
MylocalStrategy
的本地策略。为此,我添加了两个文件:mylocal.strategy.ts和mylocal-auth.guard.ts

这是我的
mylocal auth.guard.ts
内容:

import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';

@Injectable()
export class MylocalAuthGuard extends AuthGuard('mylocal') {}
但是当我使用
@UseGuards(MylocalAuthGuard)
时,我得到了一个错误:“未知身份验证策略”mylocal“


可能是什么问题?

您的
MyLocalStrategy
是否在模块定义中注册为提供程序?@ArnoldSchrijver是,它已在提供程序中注册。您的
MyLocalStrategy
是否在模块定义中注册为提供程序?@ArnoldSchrijver是,它已在提供程序中注册。