Stratal API Reference
    Preparing search index...

    Interface CanActivate

    Interface for guards that control access to routes

    Guards are executed after middlewares but before route handlers. They determine if a request should be allowed to proceed.

    class RoleGuard implements CanActivate {
    constructor(private readonly role: string) {}

    async canActivate(context: RouterContext): Promise<boolean> {
    const user = context.getUser()
    return user?.roles.includes(this.role) ?? false
    }
    }
    interface CanActivate {
        canActivate(context: RouterContext): boolean | Promise<boolean>;
    }
    Index

    Methods

    Methods