mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix(2fa): improve error handling and display for two-factor authentication setup
- Handle potential errors when enabling two-factor authentication - Provide more detailed error messages for password verification - Update client-side error handling to display specific error messages - Add base URL configuration for non-cloud environments
This commit is contained in:
@@ -64,12 +64,12 @@ export const Enable2FA = () => {
|
||||
const handlePasswordSubmit = async (formData: PasswordForm) => {
|
||||
setIsPasswordLoading(true);
|
||||
try {
|
||||
const { data: enableData } = await authClient.twoFactor.enable({
|
||||
const { data: enableData, error } = await authClient.twoFactor.enable({
|
||||
password: formData.password,
|
||||
});
|
||||
|
||||
if (!enableData) {
|
||||
throw new Error("No data received from server");
|
||||
throw new Error(error?.message || "Unknown error");
|
||||
}
|
||||
|
||||
if (enableData.backupCodes) {
|
||||
@@ -95,7 +95,7 @@ export const Enable2FA = () => {
|
||||
error instanceof Error ? error.message : "Error setting up 2FA",
|
||||
);
|
||||
passwordForm.setError("password", {
|
||||
message: "Error verifying password",
|
||||
message: `Error verifying password: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||
});
|
||||
} finally {
|
||||
setIsPasswordLoading(false);
|
||||
|
||||
@@ -14,6 +14,9 @@ const { handler, api } = betterAuth({
|
||||
provider: "pg",
|
||||
schema: schema,
|
||||
}),
|
||||
...(!IS_CLOUD && {
|
||||
baseURL: "http://localhost:3000",
|
||||
}),
|
||||
logger: {
|
||||
disabled: process.env.NODE_ENV === "production",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user