Good evening all,
today I wanted to add MFA using TOTP but failed on activating it as the last step always returns:
https://myappwriteinstacne.example.com/v1/account/mfa/authenticators/totp 401 (Unauthorized)
The user is correctly signed in and I can recieve account informations using account.get().
My code looks like this:
import { useState, useEffect } from "react";
import { account, avatars } from "./AppwriteConfig";
function Enable2fa() {
const [user, setUser] = useState<any>("");
const [qrCodeUrl, setQrCodeUrl] = useState<string>("");
const [totpSecret, setTotpSecret] = useState<string>("");
const [totpCode, setTOTPCode] = useState<string>("");
useEffect(() => {
const validateSession = async () => {
try {
const getaccount = await account.get();
setUser(getaccount);
} catch {
window.location.replace("/");
return;
}
};
const create2faTotp = async () => {
try {
const { secret, uri } = await (account as any).createMfaAuthenticator(
"totp" // type
);
const result = avatars.getQR(
uri, // url
300, // size
0, // margin
false // download
);
setQrCodeUrl(result);
setTotpSecret(secret);
} catch (error) {
console.log(error);
}
};
validateSession();
create2faTotp();
}, []);
const handleActivation = async () => {
try {
await (account as any).updateMfaAuthenticator(
"totp", // type
totpCode // otp
);
//await account.updateMFA(true);
} catch {
setMessageType("error");
setMessage(
"Failed to enable 2FA. Please verify you're logged in correctly, reload the webpage/app, or get in touch with the application owner."
);
}
};
Does anyone have an Idea on what im doing wrong here?
Many thanks and best regards Finn
Recommended threads
- Selfhost - Starting Docker containers fa...
I am stuck at installing appwrite. Specifically, the containers dont want to start up. The images are downloaded and ready. Dockhand is reporting containers st...
- It says domain already used but I have d...
I accidentally deleted the project in which I used my domain originally (orexia.app) from name.com. Now I am trying to add it to a different project and it says...
- Is this normal in the self host custom d...
when i try to add custom domain to the project did not see this in 1.8.0 ok when pressed the retry it says "DNS verification failed with resolver 8.8.8.8. Domai...