feat: Organization operations like invite and accept
This commit is contained in:
@@ -10,6 +10,7 @@ import { JwtPayload } from '../types';
|
||||
import { Request } from 'express';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { PUBLIC_KEY } from 'common/keys';
|
||||
import { UserService } from 'src/user/user.service';
|
||||
|
||||
@Injectable()
|
||||
export class AuthGuard implements CanActivate {
|
||||
@@ -17,6 +18,7 @@ export class AuthGuard implements CanActivate {
|
||||
private readonly reflector: Reflector,
|
||||
private readonly jwtService: JwtService,
|
||||
private readonly requestContext: RequestContextService,
|
||||
private readonly userService: UserService,
|
||||
) {}
|
||||
|
||||
async canActivate(context: ExecutionContext) {
|
||||
@@ -35,6 +37,10 @@ export class AuthGuard implements CanActivate {
|
||||
const payload: JwtPayload = await this.jwtService.verifyAsync(token, {
|
||||
secret: 'demo',
|
||||
});
|
||||
|
||||
// TODO: Redis + Org too, blacklist token
|
||||
const userExists = await this.userService.findById(payload.userId);
|
||||
if (!userExists) throw new UnauthorizedException();
|
||||
this.requestContext.set('user', payload);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user