mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2025-06-29 08:55:45 +08:00
Allow querying for saved login session
This commit is contained in:
parent
1f668be499
commit
f411ea00a4
11 changed files with 107 additions and 32 deletions
|
@ -6,8 +6,9 @@ import { useDispatch } from "react-redux";
|
|||
import { useNavigate } from "react-router-dom";
|
||||
import { useState } from "react";
|
||||
|
||||
import { UserLogin } from "../../Components/Api/Api";
|
||||
import { toggle_login } from "../../Features/Login/LoginSlice";
|
||||
import { UserInfo, UserLogin } from "../../Components/Api/Api";
|
||||
import { toggle_login } from "../../Features/Redux/Slices/Login/LoginSlice";
|
||||
import { SetUser } from "../../Features/Redux/Slices/LoggedInUserSlice/LoggedInUserSlice";
|
||||
|
||||
export default function Login() {
|
||||
const navigate = useNavigate();
|
||||
|
@ -68,7 +69,7 @@ export default function Login() {
|
|||
});
|
||||
if (await UserLogin(user)) {
|
||||
await dispatch(toggle_login());
|
||||
// await dispatch(SetUser(await UserInfo()));
|
||||
await dispatch(SetUser(await UserInfo()));
|
||||
navigate("/");
|
||||
} else {
|
||||
setError("Invalid Login");
|
||||
|
@ -89,6 +90,7 @@ export default function Login() {
|
|||
>
|
||||
Register
|
||||
</Button>
|
||||
<p style={{ ...styles.text_red, ...styles.text_M }}>{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue