@webda/core
Version:
Expose API with Lambda
101 lines (100 loc) • 2.57 kB
TypeScript
import { OperationContext } from "../utils/context.js";
import { CoreModel } from "./coremodel.js";
import { Ident } from "./ident.js";
import { ModelsMapped } from "./relations.js";
/**
* First basic model for User
* @class
* @WebdaModel
*/
export declare class User extends CoreModel {
/**
* Password of the user if defined
*/
__password?: string;
/**
* Display name for this user
* @optional
*/
displayName: string;
/**
* Last time the password was recovered
*/
_lastPasswordRecovery?: number;
/**
* Define the user avatar if exists
*/
_avatar?: string;
/**
* Contains the locale of the user if known
*/
locale?: string;
/**
* Contain main user email if exists
*/
email?: string;
/**
* Return user email if known or guessable
* @returns
*/
getEmail(): string | undefined;
/**
* Return displayable public entry
* @returns
*/
toPublicEntry(): any;
getGroups(): string[];
getRoles(): string[];
getDisplayName(): string;
getIdents(): Readonly<Pick<Ident, "_type" | "uuid" | "email">[]>;
lastPasswordRecoveryBefore(timestamp: number): boolean;
getPassword(): string;
setPassword(password: string): void;
canAct(ctx: OperationContext<any, any>, _action: string): Promise<string | boolean>;
/**
* Add a login/logout event
* @returns
*/
static getClientEvents(): string[];
/**
* Only current user can see its own events
* @param _event
* @param context
* @param model
* @returns
*/
static authorizeClientEvent(_event: string, context: OperationContext<any, any>, model?: CoreModel): boolean;
}
/**
* Simple user offers groups and roles management
*
* Groups and roles are defined just as string, no
* models
*/
export declare class SimpleUser extends User {
/**
* Groups for a user
*/
_groups: string[];
/**
* Roles of the user
*/
_roles: string[];
/**
* Normal ident
*/
_idents: ModelsMapped<Ident, "_user", "_type" | "uuid" | "email">;
/**
* Return idents
* @returns
*/
getIdents(): readonly import("./relations").ModelMapLoader<Ident, "uuid" | "email" | "_type">[];
addGroup(group: string): void;
inGroup(group: string): boolean;
removeGroup(group: string): void;
getGroups(): string[];
getRoles(): string[];
addRole(role: string): void;
hasRole(role: string): boolean;
removeRole(role: string): void;
}