15 lines
631 B
TypeScript
15 lines
631 B
TypeScript
|
|
import type { StartParams } from "@erp/core/api";
|
||
|
|
import type { RequestHandler } from "express";
|
||
|
|
|
||
|
|
import type { IIdentityPublicServices } from "../../../application";
|
||
|
|
|
||
|
|
export function requireIdentityAuthenticated(params: StartParams): RequestHandler[] {
|
||
|
|
const identityServices = params.getService<IIdentityPublicServices>("identity:general");
|
||
|
|
return [...identityServices.auth.authenticatedOnly()];
|
||
|
|
}
|
||
|
|
|
||
|
|
export function requireIdentityTenant(params: StartParams): RequestHandler[] {
|
||
|
|
const identityServices = params.getService<IIdentityPublicServices>("identity:general");
|
||
|
|
return [...identityServices.auth.tenantRequired()];
|
||
|
|
}
|