diff --git a/docs/docs/features/img/list-users.png b/docs/docs/features/img/list-users.png new file mode 100644 index 0000000000..02c6d8faea Binary files /dev/null and b/docs/docs/features/img/list-users.png differ diff --git a/docs/docs/features/server-commands.md b/docs/docs/features/server-commands.md index 3ad7d3363f..872f12e65a 100644 --- a/docs/docs/features/server-commands.md +++ b/docs/docs/features/server-commands.md @@ -8,6 +8,7 @@ The `immich-server` docker image comes preinstalled with an administrative CLI ( | `reset-admin-password` | Reset the password for the admin user | | `disable-password-login` | Disable password login | | `enable-password-login` | Enable password login | +| `list-users` | List Immich users | ## How to run a command @@ -26,3 +27,7 @@ Disable Password Login Enabled Password Login ![Enable Password Login](./img/enable-password-login.png) + +List Users + +![List Users](./img/list-users.png) diff --git a/server/apps/cli/src/app.module.ts b/server/apps/cli/src/app.module.ts index 91af971c7a..e38c2d749d 100644 --- a/server/apps/cli/src/app.module.ts +++ b/server/apps/cli/src/app.module.ts @@ -2,6 +2,7 @@ import { DomainModule } from '@app/domain'; import { InfraModule, SystemConfigEntity } from '@app/infra'; import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; +import { ListUsersCommand } from './commands/list-users.command'; import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from './commands/password-login'; import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command'; @@ -17,6 +18,7 @@ import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/r PromptPasswordQuestions, EnablePasswordLoginCommand, DisablePasswordLoginCommand, + ListUsersCommand, ], }) export class AppModule {} diff --git a/server/apps/cli/src/commands/list-users.command.ts b/server/apps/cli/src/commands/list-users.command.ts new file mode 100644 index 0000000000..58513ffe1b --- /dev/null +++ b/server/apps/cli/src/commands/list-users.command.ts @@ -0,0 +1,23 @@ +import { UserService } from '@app/domain'; +import { Command, CommandRunner } from 'nest-commander'; +import { CLI_USER } from '../constants'; + +@Command({ + name: 'list-users', + description: 'List Immich users', +}) +export class ListUsersCommand extends CommandRunner { + constructor(private userService: UserService) { + super(); + } + + async run(): Promise { + try { + const users = await this.userService.getAllUsers(CLI_USER, true); + console.dir(users); + } catch (error) { + console.error(error); + console.error('Unable to load users'); + } + } +} diff --git a/server/apps/cli/src/constants.ts b/server/apps/cli/src/constants.ts new file mode 100644 index 0000000000..cc9d1c72c7 --- /dev/null +++ b/server/apps/cli/src/constants.ts @@ -0,0 +1,9 @@ +import { AuthUserDto } from '@app/domain'; + +export const CLI_USER: AuthUserDto = { + id: 'cli', + email: 'cli@immich.app', + isAdmin: true, + isPublicUser: false, + isAllowUpload: true, +};