IdentityModule · packages/server/src/services/admin-service.ts:27

AdminService

component

No JSDoc comment in source yet.

API

@Component()
export class AdminService implements Admin {
  @Use() private readonly users!: Users;
  @Use() private readonly authSessions!: AuthSessions;
  @Use() private readonly liveStreams!: LiveStreams;
  @Use() private readonly projects!: Projects;
  @Use() private readonly projectService!: ProjectLifecycle;
  @Use() private readonly clock!: Clock;
  @Use() private readonly hasher!: PasswordHasher;
  listUsers(): UserInfo[];
  async createUser(userId: string, password: string): Promise<UserInfo>;
  async resetPassword(userId: string, password: string): Promise<void>;
  async deleteUser(userId: string): Promise<void>;
}

Dependencies & Wiring

Extracted from class decorators
implementsinterfaces
@Userequires (7)
users: Users · authSessions: AuthSessions · liveStreams: LiveStreams · projects: Projects · projectService: ProjectLifecycle · clock: Clock · hasher: PasswordHasher

Methods (4)

listUsers

listUsers(): UserInfo[]

Every account, for the admin user backend. The avatar is dropped on the way out: a stored avatar is a data URL of up to 128 KiB and this list is unpaged, so carrying one per account would answer a table that only shows the nickname with megabytes.

@returnsUserInfo[]

createUser

async createUser(userId: string, password: string): Promise<UserInfo>
@paramuserIdstring
@parampasswordstring
@returnsPromise<UserInfo>

resetPassword

async resetPassword(userId: string, password: string): Promise<void>

Reset a user's password and clear all their sessions (prompts a password change on next login). Only an admin reaches this route, so userId === admin is the admin resetting ITSELF: it chose a KNOWN password, which is a claimed state — not the unclaimed one the first-login link exists for — so the initial flag stays off and no link is re-opened. Every other user gets the flag, to be prompted to change the password their admin picked.

@paramuserIdstring
@parampasswordstring
@returnsPromise<void>

deleteUser

async deleteUser(userId: string): Promise<void>

Delete user: the built-in admin cannot be deleted; owned Projects (including data directories) are deleted along with it.

@paramuserIdstring
@returnsPromise<void>