2fa: refactor into separate dialog

also rename routes to totp
This commit is contained in:
Girish Ramakrishnan
2026-02-22 10:43:15 +01:00
parent a98dbfdf4f
commit d0f0bb799e
6 changed files with 147 additions and 117 deletions
+5 -5
View File
@@ -179,10 +179,10 @@ function create() {
return null;
},
async setTwoFASecret() {
async setTotpSecret() {
let error, result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/twofactorauthentication_secret`, {}, { access_token: accessToken });
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/totp_secret`, {}, { access_token: accessToken });
} catch (e) {
error = e;
}
@@ -190,10 +190,10 @@ function create() {
if (error || result.status !== 200) return [error || result];
return [null, result.body];
},
async enableTwoFA(totpToken) {
async enableTotp(totpToken) {
let error, result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/twofactorauthentication_enable`, { totpToken }, { access_token: accessToken });
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/totp_enable`, { totpToken }, { access_token: accessToken });
} catch (e) {
error = e;
}
@@ -204,7 +204,7 @@ function create() {
async disableTwoFA(password) {
let result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/twofactorauthentication_disable`, { password }, { access_token: accessToken });
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/totp_disable`, { password }, { access_token: accessToken });
} catch (e) {
return [e];
}
+1 -1
View File
@@ -202,7 +202,7 @@ function create() {
async disableTwoFactorAuthentication(id) {
let result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/users/${id}/twofactorauthentication_disable`, {}, { access_token: accessToken });
result = await fetcher.post(`${API_ORIGIN}/api/v1/users/${id}/totp_disable`, {}, { access_token: accessToken });
} catch (e) {
return [e];
}