/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
integration/graphql-code-first/src/common/guards/auth.guard.ts
18 строк
445 B
Kamil Myśliwiec
sample(): update sample to use code-first graphql
29 фев 2020, 15:21
Не верифицирован
29 фев 2020, 15:21
d2d394f
Код
Авторство
О чём код?
import { CanActivate, ExecutionContext, Injectable, UnauthorizedException, } from '@nestjs/common'; import { GqlExecutionContext } from '@nestjs/graphql'; @Injectable() export class AuthGuard implements CanActivate { async canActivate(context: ExecutionContext): Promise<boolean> { const gqlContext = GqlExecutionContext.create(context); if (gqlContext) { throw new UnauthorizedException(); } return true; } }