segunda forma de inicio de sesión, realizad
This commit is contained in:
parent
e56665ff79
commit
e059363d53
|
@ -53,7 +53,7 @@ class LoginLocalStorage extends Component {
|
|||
cookies.set('name', user.name, { path: "/" });
|
||||
cookies.set('email', user.email, { path: "/" });
|
||||
alert(`Bienvenido ${user.name}`);
|
||||
window.location.href = "./";
|
||||
window.location.href = "/";
|
||||
} else {
|
||||
alert('El usuario o la contraseña no son correctos');
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class LoginLocalStorage extends Component {
|
|||
|
||||
componentDidMount() {
|
||||
if (cookies.get('email')) {
|
||||
window.location.href = "./";
|
||||
window.location.href = "/";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ class LoginLocalStorage extends Component {
|
|||
<div className="field col-12 ">
|
||||
<label htmlFor="password">Contraseña</label>
|
||||
<InputText id="password"
|
||||
type="text"
|
||||
type="password"
|
||||
name="password"
|
||||
onChange={this.handleChange}
|
||||
placeholder='Contraseña'
|
||||
|
|
|
@ -5,8 +5,9 @@ import AdministradoresSistema from '../components/AdministradoresSistema';
|
|||
import Communities from '../components/ComunidadViviendas';
|
||||
import Dashboard from '../templates/Dashboard';
|
||||
import { BrowserRouter, Switch, Route } from 'react-router-dom';
|
||||
const cookies = new Cookies();
|
||||
import { AppMenu } from '../AppMenu';
|
||||
|
||||
const cookies = new Cookies();
|
||||
|
||||
const menu = [
|
||||
{
|
||||
|
@ -16,38 +17,54 @@ const menu = [
|
|||
{ label: 'Administradores del sistema', icon: 'pi pi-fw pi-id-card', to: '/administradoresSistema' },
|
||||
{ label: 'Administradores de comunidad', icon: 'pi pi-fw pi-id-card', to: '/administradoresComunidad' },
|
||||
{ label: 'Comunidadades', icon: 'pi pi-fw pi-id-card', to: '/comunidadesViviendas' },
|
||||
{ label: 'Log out', icon: 'pi pi-fw pi-id-card', to: '/logOut' }
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const handleLogout = () => {
|
||||
cookies.remove('id', { path: "/" });
|
||||
cookies.remove('email', { path: "/" });
|
||||
cookies.remove('name', { path: "/" });
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
class MenuAdmin extends Component {
|
||||
|
||||
state = {
|
||||
constructor(){
|
||||
super()
|
||||
this.state = {
|
||||
layoutColorMode: 'light',
|
||||
layoutMode: 'static',
|
||||
menuClick: false,
|
||||
mobileTopbarMenuClick: false,
|
||||
overlayMenuActive: false,
|
||||
mobileMenuActive: false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onSidebarClick = () => {
|
||||
this.setState({
|
||||
menuClick: true
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onMenuItemClick = (event) => {
|
||||
if (!event.item.items) {
|
||||
this.state.overlayMenuActive = false;
|
||||
this.state.mobileMenuActive = false;
|
||||
this.setState({
|
||||
overlayMenuActive: true,
|
||||
mobileMenuActive:false
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cerrarSesion = () => {
|
||||
cookies.remove('id', { path: "/" });
|
||||
cookies.remove('email', { path: "/" });
|
||||
cookies.remove('name', { path: "/" });
|
||||
window.location.href = '/';
|
||||
window.location.href = '/login';
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!cookies.get('email')) {
|
||||
window.location.href = "./";
|
||||
window.location.href = "/login";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,8 +73,10 @@ class MenuAdmin extends Component {
|
|||
return (
|
||||
<div>
|
||||
Menu Principal
|
||||
<div className="layout-sidebar" onClick={onSidebarClick}>
|
||||
<AppMenu model={menu} onMenuItemClick={onMenuItemClick} layoutColorMode={layoutColorMode} />
|
||||
<div className="layout-sidebar" onClick={this.onSidebarClick}>
|
||||
<AppMenu model={menu} onMenuItemClick={this.onMenuItemClick} layoutColorMode={this.state.layoutColorMode} />
|
||||
<button type="button" onClick={() => this.cerrarSesion()}>Logout</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="layout-main-container">
|
||||
|
@ -66,12 +85,10 @@ class MenuAdmin extends Component {
|
|||
<Route exact path="/administradoresSistema" component={AdministradoresSistema} />
|
||||
<Route path="/administradoresComunidad" component={AdministradoresComunidad} />
|
||||
<Route path="/comunidadesViviendas" component={Communities} />
|
||||
<button onClick={this.cerrarSesion}>Logout</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br />
|
||||
<button onClick={() => this.cerrarSesion()}>Cerrar Sesión</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class Menu extends Component {
|
|||
|
||||
componentDidMount() {
|
||||
if(!cookies.get('email')){
|
||||
window.location.href="./";
|
||||
window.location.href="./login";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ function Routes() {
|
|||
<BrowserRouter>
|
||||
<Switch>
|
||||
<Route exact path="/login" component={LoginLocalStorage}/>
|
||||
<Route exact path="/" component={Menu}/>
|
||||
<Route exact path="/" component={MenuAdmin}/>
|
||||
</Switch>
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue