mirror of
https://github.com/chatwoot/chatwoot.git
synced 2026-06-13 21:01:16 +08:00
## Linear Ticket - https://linear.app/chatwoot/issue/CW-6883/allow-disabling-2fa-using-a-backup-code ## Description When a user loses access to their authenticator app, they can now disable 2FA using one of their saved backup codes (in addition to their password), so they can re-enroll a new authenticator. The disable dialog includes a toggle to switch between entering a verification code and a backup code. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Via UI flows <img width="495" height="423" alt="Screenshot 2026-04-20 at 2 17 21 PM" src="https://github.com/user-attachments/assets/cc6b3dc5-39e6-4104-b5b9-cdabdc46947e" /> <img width="475" height="409" alt="Screenshot 2026-04-20 at 2 17 36 PM" src="https://github.com/user-attachments/assets/97c7304d-4adb-42ed-b7b4-50f5b38585a3" /> ## Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
29 lines
630 B
JavaScript
29 lines
630 B
JavaScript
/* global axios */
|
|
import ApiClient from './ApiClient';
|
|
|
|
class MfaAPI extends ApiClient {
|
|
constructor() {
|
|
super('profile/mfa', { accountScoped: false });
|
|
}
|
|
|
|
enable() {
|
|
return axios.post(`${this.url}`);
|
|
}
|
|
|
|
verify(otpCode) {
|
|
return axios.post(`${this.url}/verify`, { otp_code: otpCode });
|
|
}
|
|
|
|
disable(password, { otpCode, backupCode } = {}) {
|
|
return axios.delete(this.url, {
|
|
data: { password, otp_code: otpCode, backup_code: backupCode },
|
|
});
|
|
}
|
|
|
|
regenerateBackupCodes(otpCode) {
|
|
return axios.post(`${this.url}/backup_codes`, { otp_code: otpCode });
|
|
}
|
|
}
|
|
|
|
export default new MfaAPI();
|