Skip to content

Commit 84c1cb0

Browse files
committed
Tenth commit: Update frontend
1 parent 308a4f7 commit 84c1cb0

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

entregable4-frontend-2-main/src/auth/pages/Login/Login.component.jsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,26 @@ const Login = () => {
2424
}));
2525
navigate('/users/all_users');
2626
} catch (error) {
27+
const status = error.response?.status
28+
if (status === 401) {
29+
dispatch(showNotification({
30+
variant: "danger",
31+
message: "Invalid credentials",
32+
}))
33+
} else {
34+
dispatch(showNotification({
35+
variant: "danger",
36+
message: "Unexpected error, please try again",
37+
}))
38+
}
39+
40+
/*catch (error) {
2741
if(error.response.status === 401) {
2842
dispatch(showNotification({
2943
variant: "danger",
3044
message: "Invalid credentials",
3145
}));
32-
}
46+
}*/
3347
} finally { setIsLoading(false); }
3448
}
3549

@@ -49,7 +63,7 @@ const Login = () => {
4963
</Form.Text>
5064
</Form.Group>
5165

52-
<Form.Group className="mb-5" controlId="passworrd">
66+
<Form.Group className="mb-5" controlId="password">
5367
<Form.Label>Password</Form.Label>
5468
<Form.Control
5569
type="password"

entregable4-frontend-2-main/src/utils/axios.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ const axios = axiosOriginal.create({
88

99
axios.interceptors.request.use(function (config) {
1010
const token = store.getState().auth.token;
11-
if(config.headers?.Authorization) return config;
12-
config.headers.Authorization = `Bearer ${token}`;
11+
if (token) {
12+
config.headers.Authorization = `Bearer ${token}`;
13+
}
1314
return config;
15+
16+
/*if(config.headers?.Authorization) return config;
17+
config.headers.Authorization = `Bearer ${token}`;
18+
return config;*/
1419
});
1520

1621
axios.interceptors.response.use((res) => {

0 commit comments

Comments
 (0)