Skip to content

Commit

Permalink
Logout Route
Browse files Browse the repository at this point in the history
  • Loading branch information
MacKentoch committed Nov 14, 2018
1 parent 57a730b commit be9c276
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/front/components/logoutRoute/LogoutRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@

// #region imports
import React, { PureComponent } from 'react';
import { Route, Redirect, withRouter } from 'react-router-dom';
import {
type Match,
type Location,
type RouterHistory,
} from 'react-router-dom';
import auth from '../../services/auth';
import { Route, Redirect } from 'react-router-dom';
import { type AuthContextProps } from '../../contexts/auth/consumerHOC';
import { type RouterProps } from '../../types/react-router';
// #endregion

// #region flow types
type Props = {
// react-router 4:
match: Match,
location: Location,
history: RouterHistory,

...any,
};
} & RouterProps &
AuthContextProps;

type State = any;
// #endregion

class LogoutRoute extends PureComponent<Props, State> {
// #region lifecycle
componentDidMount() {
// auth.clearAllAppStorage();
// TODO: logout
const { disconnectUser } = this.props;
disconnectUser();
}

render() {
Expand All @@ -40,4 +33,4 @@ class LogoutRoute extends PureComponent<Props, State> {
// #endregion
}

export default withRouter(LogoutRoute);
export default LogoutRoute;
13 changes: 13 additions & 0 deletions src/front/components/logoutRoute/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @flow

// #region imports
import compose from 'recompose/compose';
import { withRouter } from 'react-router';
import withAuth from '../../contexts/auth/consumerHOC';
import LogoutRoute from './LogoutRoute';
// #endregion

export default compose(
withRouter,
withAuth(),
)(LogoutRoute);

0 comments on commit be9c276

Please sign in to comment.