From e39bddaf81d95cec6b1fbd4a12aef2531ed06c97 Mon Sep 17 00:00:00 2001 From: Yasmim Rosa Date: Tue, 12 Dec 2023 21:50:49 -0300 Subject: [PATCH] =?UTF-8?q?p=C3=A1ginas=20privadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/contexts/auth.js | 5 ++++- frontend/src/pages/Signin/index.js | 7 ++----- frontend/src/routes/index.js | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/contexts/auth.js b/frontend/src/contexts/auth.js index 5d1624c4..edcb5804 100644 --- a/frontend/src/contexts/auth.js +++ b/frontend/src/contexts/auth.js @@ -1,6 +1,8 @@ import { stubFalse } from "lodash"; +import { stubFalse } from "lodash"; import { createContext, useEffect, useState } from "react"; import Signin from "../pages/Signin"; +import Signin from "../pages/Signin"; export const AuthContext = createContext({}); @@ -16,6 +18,7 @@ export const AuthProvider = ({ children }) => { }; const signout = () => { + sessionStorage.removeItem("accessToken"); sessionStorage.removeItem("accessToken"); sessionStorage.removeItem("superuser"); }; @@ -37,4 +40,4 @@ export const AuthProvider = ({ children }) => { {children} ); -}; +} diff --git a/frontend/src/pages/Signin/index.js b/frontend/src/pages/Signin/index.js index fc3379df..a727c416 100644 --- a/frontend/src/pages/Signin/index.js +++ b/frontend/src/pages/Signin/index.js @@ -28,12 +28,9 @@ const Signin = () => { if (response.data.accessToken) { sessionStorage.setItem("accessToken", response.data.accessToken); - sessionStorage.setItem("superuser", response.data.superuser); - + sessionStorage.setItem("user", JSON.stringify({email, senha})); signin(); - console.log("oi") - console.log( sessionStorage.getItem("superuser")) - console.log(isSuperUser()) + navigate("/home"); diff --git a/frontend/src/routes/index.js b/frontend/src/routes/index.js index 418ef830..db0e7db5 100644 --- a/frontend/src/routes/index.js +++ b/frontend/src/routes/index.js @@ -1,5 +1,7 @@ import React from "react"; import { Navigate, Route, BrowserRouter, Routes } from "react-router-dom"; +import React from "react"; +import { Navigate, Route, BrowserRouter, Routes } from "react-router-dom"; import useAuth from "../hooks/useAuth"; import Home from "../pages/Home"; import Signin from "../pages/Signin";