Created
June 14, 2018 09:12
-
-
Save vdelacou/7cab6528fb5e29d0e32be5aee2a06dec to your computer and use it in GitHub Desktop.
Change jhipster Logout with Auth0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { connect } from 'react-redux'; | |
import { Redirect } from 'react-router-dom'; | |
import { IRootState } from 'app/shared/reducers'; | |
import { logout } from 'app/shared/reducers/authentication'; | |
import Auth0 from 'app/config/auth0'; | |
export interface ILogoutProps extends StateProps, DispatchProps { } | |
export class Logout extends React.Component<ILogoutProps> { | |
componentDidMount() { | |
const auth0 = new Auth0(); | |
auth0.lock.logout({ returnTo: '/' }); | |
this.props.logout(); | |
} | |
render() { | |
return ( | |
<div className="p-5"> | |
<h4>Logged out successfully!</h4> | |
<Redirect to={{ | |
pathname: '/' | |
}} /> | |
</div> | |
); | |
} | |
} | |
const mapStateToProps = (storeState: IRootState) => ({}); | |
const mapDispatchToProps = { logout }; | |
type StateProps = ReturnType<typeof mapStateToProps>; | |
type DispatchProps = typeof mapDispatchToProps; | |
export default connect(mapStateToProps, mapDispatchToProps)(Logout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment