request (options: OverrideCommandOptions & {
userId: number
- currentPassword: string
+ currentPassword?: string
}) {
const { currentPassword, userId } = options
disable (options: OverrideCommandOptions & {
userId: number
- currentPassword: string
+ currentPassword?: string
}) {
const { userId, currentPassword } = options
const path = '/api/v1/users/' + userId + '/two-factor/disable'
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
+ }
}