diff --git a/src/routes/signup/company.tsx b/src/routes/signup/company.tsx index e316a97..7e95590 100644 --- a/src/routes/signup/company.tsx +++ b/src/routes/signup/company.tsx @@ -216,6 +216,22 @@ export default function CompanySignupRoute() { return; } setVerifiedSuccess(true); + // Auto-login after verification + const loginRes = await fetch("/api/auth/login", { + method: "POST", + headers: { "Content-Type": "application/json", Accept: "application/json" }, + credentials: "include", + body: JSON.stringify({ + email: pendingEmail() || email().trim().toLowerCase(), + password: password(), + }), + }); + const loginData = await loginRes.json().catch(() => ({})); + if (loginRes.ok && loginData?.access_token) { + if (typeof window !== "undefined") { + window.sessionStorage.setItem("nxtgauge_access_token", loginData.access_token); + } + } setTimeout(() => navigate("/dashboard?role=COMPANY", { replace: true }), 1400); } catch (err) { setServerError("Network error — please try again."); diff --git a/src/routes/signup/customer.tsx b/src/routes/signup/customer.tsx index fa9866a..953f9cc 100644 --- a/src/routes/signup/customer.tsx +++ b/src/routes/signup/customer.tsx @@ -213,6 +213,22 @@ export default function CustomerSignupRoute() { return; } setVerifiedSuccess(true); + // Auto-login after verification + const loginRes = await fetch("/api/auth/login", { + method: "POST", + headers: { "Content-Type": "application/json", Accept: "application/json" }, + credentials: "include", + body: JSON.stringify({ + email: pendingEmail() || email().trim().toLowerCase(), + password: password(), + }), + }); + const loginData = await loginRes.json().catch(() => ({})); + if (loginRes.ok && loginData?.access_token) { + if (typeof window !== "undefined") { + window.sessionStorage.setItem("nxtgauge_access_token", loginData.access_token); + } + } setTimeout(() => navigate("/dashboard?role=CUSTOMER", { replace: true }), 1400); } catch (err) { setServerError("Network error — please try again."); diff --git a/src/routes/signup/jobseeker.tsx b/src/routes/signup/jobseeker.tsx index bbe9814..6c9f0f5 100644 --- a/src/routes/signup/jobseeker.tsx +++ b/src/routes/signup/jobseeker.tsx @@ -203,6 +203,22 @@ export default function JobSeekerSignupRoute() { return; } setVerifiedSuccess(true); + // Auto-login after verification + const loginRes = await fetch("/api/auth/login", { + method: "POST", + headers: { "Content-Type": "application/json", Accept: "application/json" }, + credentials: "include", + body: JSON.stringify({ + email: pendingEmail() || email().trim().toLowerCase(), + password: password(), + }), + }); + const loginData = await loginRes.json().catch(() => ({})); + if (loginRes.ok && loginData?.access_token) { + if (typeof window !== "undefined") { + window.sessionStorage.setItem("nxtgauge_access_token", loginData.access_token); + } + } setTimeout(() => navigate("/dashboard?role=JOB_SEEKER", { replace: true }), 1400); } catch (err) { setServerError("Network error — please try again."); diff --git a/src/routes/signup/professional.tsx b/src/routes/signup/professional.tsx index 3b1533e..94e910f 100644 --- a/src/routes/signup/professional.tsx +++ b/src/routes/signup/professional.tsx @@ -222,6 +222,22 @@ export default function ProfessionalSignupRoute() { return; } setVerifiedSuccess(true); + // Auto-login after verification + const loginRes = await fetch("/api/auth/login", { + method: "POST", + headers: { "Content-Type": "application/json", Accept: "application/json" }, + credentials: "include", + body: JSON.stringify({ + email: pendingEmail() || email().trim().toLowerCase(), + password: password(), + }), + }); + const loginData = await loginRes.json().catch(() => ({})); + if (loginRes.ok && loginData?.access_token) { + if (typeof window !== "undefined") { + window.sessionStorage.setItem("nxtgauge_access_token", loginData.access_token); + } + } setTimeout(() => navigate("/dashboard?role=PROFESSIONAL", { replace: true }), 1400); } catch (err) { setServerError("Network error — please try again.");