Skip to content

Commit

Permalink
páginas privadas
Browse files Browse the repository at this point in the history
  • Loading branch information
yaskisoba committed Dec 13, 2023
1 parent adb8b7c commit e39bdda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion frontend/src/contexts/auth.js
Original file line number Diff line number Diff line change
@@ -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({});

Expand All @@ -16,6 +18,7 @@ export const AuthProvider = ({ children }) => {
};

const signout = () => {
sessionStorage.removeItem("accessToken");
sessionStorage.removeItem("accessToken");
sessionStorage.removeItem("superuser");
};
Expand All @@ -37,4 +40,4 @@ export const AuthProvider = ({ children }) => {
{children}
</AuthContext.Provider>
);
};
}
7 changes: 2 additions & 5 deletions frontend/src/pages/Signin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");


Expand Down
2 changes: 2 additions & 0 deletions frontend/src/routes/index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit e39bdda

Please sign in to comment.