Skip to content

Commit 1e302a6

Browse files
committed
fix(dashboard): correct user extraction from ApiResponse in login flow
The frontend was incorrectly referencing response.data.user instead of response.data.data.user after a recent backend response format change using ApiResponse. This caused the login and auth check to fail, resulting in immediate redirects back to the login page.
1 parent 1b65e78 commit 1e302a6

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

apps/web-dashboard/src/context/AuthContext.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const AuthProvider = ({ children }) => {
1212
try {
1313
const response = await api.get('/api/auth/me');
1414
if (response.data.success) {
15-
setUser(response.data.user);
15+
setUser(response.data.data.user);
1616
}
1717
} catch (err) {
1818
console.error("Not authenticated:", err.message);

apps/web-dashboard/src/pages/Login.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function Login() {
6767
const response = await api.post('/api/auth/login', formData);
6868

6969
if (response.data.success) {
70-
login(response.data.user);
70+
login(response.data.data.user);
7171
toast.dismiss(loadingToast);
7272
toast.success('Welcome back.');
7373
navigate('/dashboard');

apps/web-dashboard/src/pages/OtpVerification.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function OtpVerification() {
5858
toast.success('Email verified successfully!');
5959

6060
if (res.data.success) {
61-
login(res.data.user);
61+
login(res.data.data.user);
6262
}
6363
navigate('/dashboard');
6464
} catch (err) {

0 commit comments

Comments
 (0)