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:
parent
d12b40fb96
commit
2166c058f3
17 changed files with 201 additions and 81 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue