Changeset 5528b99 for frontend/src/Components/Hooks/User
- Timestamp:
- 01/16/24 16:34:03 (10 months ago)
- Branches:
- master
- Children:
- 07f4e8b
- Parents:
- e6c2521
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/Components/Hooks/User/useLogin.js
re6c2521 r5528b99 4 4 import { Navigate, useAsyncValue, useNavigate } from "react-router-dom"; 5 5 import LoginForm from "../../Login/LoginForm.js"; 6 import {useAuth} from "../../Context/AuthContext";7 6 8 7 const useLogin = () => { 9 8 10 9 const navigator = useNavigate() 11 const Auth = useAuth();12 10 //const history = useNavigate(); 13 11 const login = async (loginData) => { … … 24 22 }) 25 23 .then((res) => { 26 console.log("RES LOGIN")27 console.log(res)28 if(res.status === 200)29 {30 const user = {31 sessionId: res.data.auth.details.sessionId,32 userId: res.data.auth.principal.userID,33 username: res.data.auth.principal.username,34 role: res.data.auth.principal.role,35 name: res.data.auth.principal.name,36 surname: res.data.auth.principal.surname,37 }38 Auth.userLogin(user);39 console.log(user)40 }41 24 const sessionId = res.data.auth.details.sessionId; 42 25 const userId = res.data.auth.principal.userID; 43 26 44 27 localStorage.setItem("sessionId", sessionId); 45 28 localStorage.setItem("userId", userId);
Note:
See TracChangeset
for help on using the changeset viewer.