feat(cli): list users (#1341)

This commit is contained in:
Jason Rasmussen 2023-01-16 19:31:46 -05:00 committed by GitHub
parent 177cc3d7f9
commit adacfb1110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -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)

View File

@ -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 {}

View File

@ -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');
}
}
}

View File

@ -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,
};