Class RolesGuardProvider

Hierarchy

  • RolesGuardProvider

Implements

  • CanActivate

Constructors

Properties

Methods

Constructors

Properties

reflector: Reflector

Methods

  • Parameters

    • context: ExecutionContext

    Returns Promise<{
        role: number;
    }>

    Description

    • This method for override

    Example

    const request = context.switchToHttp().getRequest();
    const { login, sessionId } = request.cookies;
    if (!login || !sessionId) throw new AuthorizationNotAuthorizedError();
    // get user from db, or somewhere else
    if (!user) throw new AuthorizationNotAuthorizedError();
    return user.role;

Generated using TypeDoc