Commit 042cdaa5 authored by IamI's avatar IamI

Logout

parent 51f90420
......@@ -9,6 +9,8 @@ import Index from './routes/Index.js';
import Login from './routes/Login.js';
import Logout from './routes/Logout.js'
import Profiles from './routes/Profiles.js';
import Register from './routes/Register.js';
......@@ -23,6 +25,8 @@ function RouterConfig({ history }) {
<Router history={history}>
<Route path="/" component={Index}>
<Route path="/signin" component={Login}/>
<Route path="/signout" component={Logout}/>
<Route path="/forgot" component={Forgot}/>
<Route path="/signup" component={Register}/>
<Route path="/reset" component={Reset}/>
......
import { connect } from 'dva';
import React from 'react';
class Logout extends React.Component {
componentDidMount() {
window.localStorage.removeItem('token');
const url = new URL(window.location.href);
const redirect = url.searchParams.get('redirect') || '/';
window.location.href = redirect;
}
render() {
return null;
}
}
function mapStateToProps(state) {
const loading = state.loading.global || false;
return {
loading,
};
}
export default connect(mapStateToProps)(Logout);
Markdown is supported
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