mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactor(nestjs): hook up auth endpoints
This commit is contained in:
@@ -10,11 +10,15 @@ import { Reflector } from '@nestjs/core';
|
||||
import { IS_PUBLIC_ROUTE } from '../Auth/Auth.constants';
|
||||
|
||||
export const IS_IGNORE_TENANT_INITIALIZED = 'IS_IGNORE_TENANT_INITIALIZED';
|
||||
export const IgnoreTenantInitializedRoute = () => SetMetadata(IS_IGNORE_TENANT_INITIALIZED, true);
|
||||
export const IgnoreTenantInitializedRoute = () =>
|
||||
SetMetadata(IS_IGNORE_TENANT_INITIALIZED, true);
|
||||
|
||||
@Injectable()
|
||||
export class EnsureTenantIsInitializedGuard implements CanActivate {
|
||||
constructor(private readonly tenancyContext: TenancyContext, private reflector: Reflector) {}
|
||||
constructor(
|
||||
private readonly tenancyContext: TenancyContext,
|
||||
private reflector: Reflector,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Validate the tenant of the current request is initialized..
|
||||
@@ -22,10 +26,11 @@ export class EnsureTenantIsInitializedGuard implements CanActivate {
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const isIgnoreEnsureTenantInitialized = this.reflector.getAllAndOverride<boolean>(
|
||||
IS_IGNORE_TENANT_INITIALIZED,
|
||||
[context.getHandler(), context.getClass()],
|
||||
);
|
||||
const isIgnoreEnsureTenantInitialized =
|
||||
this.reflector.getAllAndOverride<boolean>(IS_IGNORE_TENANT_INITIALIZED, [
|
||||
context.getHandler(),
|
||||
context.getClass(),
|
||||
]);
|
||||
const isPublic = this.reflector.getAllAndOverride<boolean>(
|
||||
IS_PUBLIC_ROUTE,
|
||||
[context.getHandler(), context.getClass()],
|
||||
|
||||
Reference in New Issue
Block a user