diff --git a/resources/scripts/download.js b/resources/scripts/download.js index aeb6993a..4b760343 100644 --- a/resources/scripts/download.js +++ b/resources/scripts/download.js @@ -10,7 +10,7 @@ import fs from 'fs' */ export async function downloadWithRedirects(url, destinationPath) { return new Promise((resolve, reject) => { - const timeoutMs = 3 * 60 * 1000; // 3 minutes + const timeoutMs = 5 * 60 * 1000; // 10 minutes const timeout = setTimeout(() => { reject(new Error(`timeout(${timeoutMs / 1000} seconds)`)); }, timeoutMs); @@ -113,4 +113,3 @@ export async function downloadWithRedirects(url, destinationPath) { request(url) }) } - diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 1a04220b..ca8a09a2 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -65,6 +65,35 @@ export default function Login() { return !newErrors.email && !newErrors.password; }; + const getLoginErrorMessage = (data: any) => { + if (!data || typeof data !== "object" || typeof data.code !== "number") { + return ""; + } + + if (data.code === 0) { + return ""; + } + + if (data.code === 10) { + return data.text || t("layout.login-failed-please-check-your-email-and-password"); + } + + if (data.code === 1 && Array.isArray(data.error) && data.error.length > 0) { + const firstError = data.error[0]; + if (typeof firstError === "string") { + return firstError; + } + if (typeof firstError?.msg === "string") { + return firstError.msg; + } + if (typeof firstError?.message === "string") { + return firstError.message; + } + } + + return data.text || t("layout.login-failed-please-try-again"); + }; + const handleInputChange = (field: string, value: string) => { setFormData((prev) => ({ ...prev, @@ -97,8 +126,9 @@ export default function Login() { password: formData.password, }); - if (data.code === 10) { - setGeneralError(data.text || t("layout.login-failed-please-try-again")); + const errorMessage = getLoginErrorMessage(data); + if (errorMessage) { + setGeneralError(errorMessage); return; } @@ -122,8 +152,9 @@ export default function Login() { token: token, }); - if (data.code === 10) { - setGeneralError(data.text || t("layout.login-failed-please-try-again")); + const errorMessage = getLoginErrorMessage(data); + if (errorMessage) { + setGeneralError(errorMessage); return; } console.log("data", data); @@ -294,7 +325,13 @@ export default function Login() {