aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/server-commands/users/two-factor-command.ts21
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}