1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Allow admins to disable two factor auth

This commit is contained in:
Chocobozzz 2022-10-07 14:23:42 +02:00
parent d12b40fb96
commit 2166c058f3
No known key found for this signature in database
GPG key ID: 583A612D890159BE
17 changed files with 201 additions and 81 deletions

View file

@ -21,7 +21,7 @@ export class TwoFactorCommand extends AbstractCommand {
request (options: OverrideCommandOptions & {
userId: number
currentPassword: string
currentPassword?: string
}) {
const { currentPassword, userId } = options
@ -58,7 +58,7 @@ export class TwoFactorCommand extends AbstractCommand {
disable (options: OverrideCommandOptions & {
userId: number
currentPassword: string
currentPassword?: string
}) {
const { userId, currentPassword } = options
const path = '/api/v1/users/' + userId + '/two-factor/disable'
@ -72,4 +72,21 @@ export class TwoFactorCommand extends AbstractCommand {
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
async requestAndConfirm (options: OverrideCommandOptions & {
userId: number
currentPassword?: string
}) {
const { userId, currentPassword } = options
const { otpRequest } = await this.request({ userId, currentPassword })
await this.confirmRequest({
userId,
requestToken: otpRequest.requestToken,
otpToken: TwoFactorCommand.buildOTP({ secret: otpRequest.secret }).generate()
})
return otpRequest
}
}