feat: Organization operations like invite and accept

This commit is contained in:
sauravdhakal12
2026-02-22 17:27:37 +05:45
parent afed1731d2
commit 90b0192cd2
22 changed files with 1604 additions and 73 deletions

View File

@@ -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;