Skip to content

Commit adacfb1

Browse files
authored
feat(cli): list users (immich-app#1341)
1 parent 177cc3d commit adacfb1

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed
35.4 KB
Loading

docs/docs/features/server-commands.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The `immich-server` docker image comes preinstalled with an administrative CLI (
88
| `reset-admin-password` | Reset the password for the admin user |
99
| `disable-password-login` | Disable password login |
1010
| `enable-password-login` | Enable password login |
11+
| `list-users` | List Immich users |
1112

1213
## How to run a command
1314

@@ -26,3 +27,7 @@ Disable Password Login
2627
Enabled Password Login
2728

2829
![Enable Password Login](./img/enable-password-login.png)
30+
31+
List Users
32+
33+
![List Users](./img/list-users.png)

server/apps/cli/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DomainModule } from '@app/domain';
22
import { InfraModule, SystemConfigEntity } from '@app/infra';
33
import { Module } from '@nestjs/common';
44
import { TypeOrmModule } from '@nestjs/typeorm';
5+
import { ListUsersCommand } from './commands/list-users.command';
56
import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from './commands/password-login';
67
import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command';
78

@@ -17,6 +18,7 @@ import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/r
1718
PromptPasswordQuestions,
1819
EnablePasswordLoginCommand,
1920
DisablePasswordLoginCommand,
21+
ListUsersCommand,
2022
],
2123
})
2224
export class AppModule {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { UserService } from '@app/domain';
2+
import { Command, CommandRunner } from 'nest-commander';
3+
import { CLI_USER } from '../constants';
4+
5+
@Command({
6+
name: 'list-users',
7+
description: 'List Immich users',
8+
})
9+
export class ListUsersCommand extends CommandRunner {
10+
constructor(private userService: UserService) {
11+
super();
12+
}
13+
14+
async run(): Promise<void> {
15+
try {
16+
const users = await this.userService.getAllUsers(CLI_USER, true);
17+
console.dir(users);
18+
} catch (error) {
19+
console.error(error);
20+
console.error('Unable to load users');
21+
}
22+
}
23+
}

server/apps/cli/src/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { AuthUserDto } from '@app/domain';
2+
3+
export const CLI_USER: AuthUserDto = {
4+
id: 'cli',
5+
email: 'cli@immich.app',
6+
isAdmin: true,
7+
isPublicUser: false,
8+
isAllowUpload: true,
9+
};

0 commit comments

Comments
 (0)