Commit 8e0ec185 authored by Damien's avatar Damien
Browse files

Oauth for the front

parent 3e597060
import React from 'react';
import { BrowserRouter as Router, Route, Redirect} from 'react-router-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import './App.css';
import MainPage from './view/mainPage';
import Login from './view/Login';
import env from './.env'
import isLogged from './utils/Oauth';
function App() {
return (
<Router >
<Route exact path='/' render={()=>false ? <MainPage/> : window.location=`${env.backURL}/oauth/login`}/>
<Route exact path='/' render={()=>isLogged() ? <MainPage/> : window.location=`${env.backURL}/oauth/login`}/>
<Route exact path='/login/:token' component={Login} />
</Router>
);
......
function isLogged() {
let token = localStorage.getItem("token");
if (token) {
return ((/^ey.*/).test(token))
}
return false;
}
export default isLogged;
......@@ -5,12 +5,13 @@ class Login extends Component {
componentDidMount(){
localStorage.setItem("token",this.props.match.params.token);
console.log(localStorage.getItem("token"));
window.location = '/';
}
render(){
return (
<div>tesst</div>
<div>Vous allez être redirigé</div>
)
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment