diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-07 14:23:42 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-07 14:28:35 +0200 |
commit | 2166c058f34dff6f91566930d12448805d829de7 (patch) | |
tree | 2b9100b8eccbac287d1105c765901f966a354986 /shared | |
parent | d12b40fb96d56786a96c06a621f3d8e0a0d24f4a (diff) | |
download | PeerTube-2166c058f34dff6f91566930d12448805d829de7.tar.gz PeerTube-2166c058f34dff6f91566930d12448805d829de7.tar.zst PeerTube-2166c058f34dff6f91566930d12448805d829de7.zip |
Allow admins to disable two factor auth
Diffstat (limited to 'shared')
-rw-r--r-- | shared/server-commands/users/two-factor-command.ts | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/shared/server-commands/users/two-factor-command.ts b/shared/server-commands/users/two-factor-command.ts index 6c9d270ae..5542acfda 100644 --- a/shared/server-commands/users/two-factor-command.ts +++ b/shared/server-commands/users/two-factor-command.ts | |||
@@ -21,7 +21,7 @@ export class TwoFactorCommand extends AbstractCommand { | |||
21 | 21 | ||
22 | request (options: OverrideCommandOptions & { | 22 | request (options: OverrideCommandOptions & { |
23 | userId: number | 23 | userId: number |
24 | currentPassword: string | 24 | currentPassword?: string |
25 | }) { | 25 | }) { |
26 | const { currentPassword, userId } = options | 26 | const { currentPassword, userId } = options |
27 | 27 | ||
@@ -58,7 +58,7 @@ export class TwoFactorCommand extends AbstractCommand { | |||
58 | 58 | ||
59 | disable (options: OverrideCommandOptions & { | 59 | disable (options: OverrideCommandOptions & { |
60 | userId: number | 60 | userId: number |
61 | currentPassword: string | 61 | currentPassword?: string |
62 | }) { | 62 | }) { |
63 | const { userId, currentPassword } = options | 63 | const { userId, currentPassword } = options |
64 | const path = '/api/v1/users/' + userId + '/two-factor/disable' | 64 | const path = '/api/v1/users/' + userId + '/two-factor/disable' |
@@ -72,4 +72,21 @@ export class TwoFactorCommand extends AbstractCommand { | |||
72 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | 72 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 |
73 | }) | 73 | }) |
74 | } | 74 | } |
75 | |||
76 | async requestAndConfirm (options: OverrideCommandOptions & { | ||
77 | userId: number | ||
78 | currentPassword?: string | ||
79 | }) { | ||
80 | const { userId, currentPassword } = options | ||
81 | |||
82 | const { otpRequest } = await this.request({ userId, currentPassword }) | ||
83 | |||
84 | await this.confirmRequest({ | ||
85 | userId, | ||
86 | requestToken: otpRequest.requestToken, | ||
87 | otpToken: TwoFactorCommand.buildOTP({ secret: otpRequest.secret }).generate() | ||
88 | }) | ||
89 | |||
90 | return otpRequest | ||
91 | } | ||
75 | } | 92 | } |