fix(signup): auto-login after OTP verification
Some checks failed
build-and-release / build (push) Failing after 1m17s
Some checks failed
build-and-release / build (push) Failing after 1m17s
This commit is contained in:
parent
3ee5e908cf
commit
38c7b4022d
4 changed files with 64 additions and 0 deletions
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue