fix(auth): complete login by reading userinfo from response envelope
oauth/userinfo returns { success, data: {...} }, so after the interceptor
unwraps once the user lives at res.data, not res. getInfo checked
res.uuid (undefined), so it never set the userInfo cookie or redirected —
the /login page just sat there after entering the OTP. Read res.data,
store the user object (with a username alias for mobile_number so the
appointment flow keeps working), redirect via location.href, and show a
toast instead of silently staying when userinfo fails.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -84,20 +84,26 @@ function SendReq({
|
||||
})
|
||||
.then((res) => {
|
||||
setLoading(false);
|
||||
if (res && res.uuid) {
|
||||
Cookies.set("userInfo", JSON.stringify(res), cookieOptions);
|
||||
const profile = res?.data;
|
||||
if (profile?.uuid) {
|
||||
const userInfo = { ...profile, username: profile.mobile_number };
|
||||
Cookies.set("userInfo", JSON.stringify(userInfo), cookieOptions);
|
||||
|
||||
// اگر در صفحه appointment هستیم، به مرحله 3 (Detail) میرویم
|
||||
if (setStep) {
|
||||
setStep(3);
|
||||
} else {
|
||||
window.location.pathname = "/";
|
||||
window.location.href = "/";
|
||||
}
|
||||
} else {
|
||||
setIsError(true);
|
||||
toast.error("دریافت اطلاعات کاربر ناموفق بود. دوباره تلاش کنید.");
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
setLoading(false);
|
||||
setIsError(true);
|
||||
toast.error("دریافت اطلاعات کاربر ناموفق بود. دوباره تلاش کنید.");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user