High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(cli): list users (#1341)
Jason Rasmussenadacfb111015
diff --git a/docs/docs/features/img/list-users.png b/docs/docs/features/img/list-users.pngnew file mode 100644index 0000000000..02c6d8faeaBinary files /dev/null and b/docs/docs/features/img/list-users.png differdiff --git a/docs/docs/features/server-commands.md b/docs/docs/features/server-commands.mdindex 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 LoginEnabled Password Login++List Users++diff --git a/server/apps/cli/src/app.module.ts b/server/apps/cli/src/app.module.tsindex 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/rPromptPasswordQuestions,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.tsnew file mode 100644index 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<void> {+ 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.tsnew file mode 100644index 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: '[email protected]',+ isAdmin: true,+ isPublicUser: false,+ isAllowUpload: true,+};