Skip to content
Snippets Groups Projects

Release 1

Merged Martin Mechtel requested to merge release-1 into develop
32 files
+ 455
191
Compare changes
  • Side-by-side
  • Inline
Files
32
+ 23
0
import {
CanActivate, ExecutionContext, Injectable, UnauthorizedException
} from '@nestjs/common';
import { AuthService } from './service/auth.service';
@Injectable()
export class IdmGuard implements CanActivate {
constructor(
private authService: AuthService
) {}
async canActivate(
context: ExecutionContext
) {
const req = context.switchToHttp().getRequest();
const userId = req.user.id;
const isAdmin = await this.authService.isCmsAdminUser(userId);
if (!isAdmin) {
throw new UnauthorizedException();
}
return true;
}
}
Loading