- Rename from @lossless.zone/s3container to @lossless.zone/objectstorage - Replace @push.rocks/smarts3 with @push.rocks/smartstorage - Change env var prefix from S3_ to OBJST_ - Rename S3Container class to ObjectStorageContainer - Update web component prefix from s3c- to objst- - Update UI labels, CLI flags, documentation, and Docker config
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import * as plugins from '../../plugins.ts';
|
|
import type { AdminHandler } from '../handlers/admin.handler.ts';
|
|
import * as interfaces from '../../../ts_interfaces/index.ts';
|
|
|
|
export async function requireValidIdentity<T extends { identity?: interfaces.data.IIdentity }>(
|
|
adminHandler: AdminHandler,
|
|
dataArg: T,
|
|
): Promise<void> {
|
|
if (!dataArg.identity) {
|
|
throw new plugins.typedrequest.TypedResponseError('No identity provided');
|
|
}
|
|
const passed = await adminHandler.validIdentityGuard.exec({ identity: dataArg.identity });
|
|
if (!passed) {
|
|
throw new plugins.typedrequest.TypedResponseError('Valid identity required');
|
|
}
|
|
}
|
|
|
|
export async function requireAdminIdentity<T extends { identity?: interfaces.data.IIdentity }>(
|
|
adminHandler: AdminHandler,
|
|
dataArg: T,
|
|
): Promise<void> {
|
|
if (!dataArg.identity) {
|
|
throw new plugins.typedrequest.TypedResponseError('No identity provided');
|
|
}
|
|
const passed = await adminHandler.adminIdentityGuard.exec({ identity: dataArg.identity });
|
|
if (!passed) {
|
|
throw new plugins.typedrequest.TypedResponseError('Admin access required');
|
|
}
|
|
}
|