guard,守卫,身份验证用的吧,创建一个,nest generate guard demoAuth core/guards

This commit is contained in:
Jeremy Yin 2019-06-19 21:33:11 +08:00
parent 8f9ae7d1b9
commit d20d72db9a
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import { DemoAuthGuard } from './demo-auth.guard';
describe('DemoAuthGuard', () => {
it('should be defined', () => {
expect(new DemoAuthGuard()).toBeDefined();
});
});

View File

@ -0,0 +1,11 @@
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable()
export class DemoAuthGuard implements CanActivate {
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
return true;
}
}