diff --git a/docs/docs/administration/server-commands.md b/docs/docs/administration/server-commands.md index fc235f5a58..2594da44b2 100644 --- a/docs/docs/administration/server-commands.md +++ b/docs/docs/administration/server-commands.md @@ -8,6 +8,8 @@ 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 | +| `enable-oauth-login` | Enable OAuth login | +| `disable-oauth-login` | Disable OAuth login | | `list-users` | List Immich users | ## How to run a command @@ -36,13 +38,27 @@ immich-admin disable-password-login Password login has been disabled. ``` -Enabled Password Login +Enable Password Login ``` immich-admin enable-password-login Password login has been enabled. ``` +Enable OAuth login + +``` +immich-admin enable-oauth-login +OAuth login has been enabled. +``` + +Disable OAuth login + +``` +immich-admin disable-oauth-login +OAuth login has been disabled. +``` + List Users ``` diff --git a/server/src/immich-admin/app.module.ts b/server/src/immich-admin/app.module.ts index 293e43c092..b350aec83e 100644 --- a/server/src/immich-admin/app.module.ts +++ b/server/src/immich-admin/app.module.ts @@ -2,6 +2,7 @@ import { DomainModule } from '@app/domain'; import { InfraModule } from '@app/infra'; import { Module } from '@nestjs/common'; import { ListUsersCommand } from './commands/list-users.command'; +import { DisableOAuthLogin, EnableOAuthLogin } from './commands/oauth-login'; import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from './commands/password-login'; import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/reset-admin-password.command'; @@ -12,6 +13,8 @@ import { PromptPasswordQuestions, ResetAdminPasswordCommand } from './commands/r PromptPasswordQuestions, EnablePasswordLoginCommand, DisablePasswordLoginCommand, + EnableOAuthLogin, + DisableOAuthLogin, ListUsersCommand, ], }) diff --git a/server/src/immich-admin/commands/oauth-login.ts b/server/src/immich-admin/commands/oauth-login.ts new file mode 100644 index 0000000000..23747bf03a --- /dev/null +++ b/server/src/immich-admin/commands/oauth-login.ts @@ -0,0 +1,36 @@ +import { SystemConfigService } from '@app/domain'; +import { Command, CommandRunner } from 'nest-commander'; + +@Command({ + name: 'enable-oauth-login', + description: 'Enable OAuth login', +}) +export class EnableOAuthLogin extends CommandRunner { + constructor(private configService: SystemConfigService) { + super(); + } + + async run(): Promise { + const config = await this.configService.getConfig(); + config.oauth.enabled = true; + await this.configService.updateConfig(config); + console.log('OAuth login has been enabled.'); + } +} + +@Command({ + name: 'disable-oauth-login', + description: 'Disable OAuth login', +}) +export class DisableOAuthLogin extends CommandRunner { + constructor(private configService: SystemConfigService) { + super(); + } + + async run(): Promise { + const config = await this.configService.getConfig(); + config.oauth.enabled = false; + await this.configService.updateConfig(config); + console.log('OAuth login has been disabled.'); + } +}