Skip to content

Commit

Permalink
Merge pull request #204 from Arquisoft/isAdmin
Browse files Browse the repository at this point in the history
Roles
  • Loading branch information
uo276514 authored May 1, 2022
2 parents 16e5989 + 2d7575f commit 3572715
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 0 additions & 4 deletions webapp/src/componentes/Login/LoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ const LoginButton = () => {
let user = JSON.parse(localUser);
} else {
localStorage.setItem("user", JSON.stringify([]));
localStorage.setItem("isAdmin", user?.email != null ?
user?.email
: ""
);
}

}}>Registrarse</button>;
Expand Down
15 changes: 13 additions & 2 deletions webapp/src/paginas/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useAuth0 } from "@auth0/auth0-react";
import { Usuario } from "../shared/sharedUser";
import "./Pag.css"

// Variable para almacenar si el usuario autenticado existe o no en la bd
Expand All @@ -15,6 +16,7 @@ export async function checkUserInBDByEmail(email:string): Promise<any> {
.then(usuario => {
userExists = usuario.isAdmin;
console.log(usuario.isAdmin);
localStorage.setItem("isAdmin", usuario.isAdmin);
});
//The objects returned by the api are directly convertible to User objects
return response;
Expand All @@ -34,11 +36,20 @@ async function addUserToBD(email:string): Promise<any> {

return response;
}

/*
export async function checkUserInBD(): Promise<Usuario[]> {
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/'
//const apiEndPoint= process.env.REACT_APP_API_URI || 'https://dede-en2a-restapi.herokuapp.com'
let response = await fetch(apiEndPoint +"usuario");
//The objects returned by the api are directly convertible to User objects
console.log(response.json());
return response.json();
}
*/
const Home = () => {

const {isAuthenticated, user} = useAuth0();

let usuario:Usuario;
if(isAuthenticated){
// comprobamos si ya existe en la bd
let email:any = user?.email;
Expand Down

0 comments on commit 3572715

Please sign in to comment.