Skip to content

Instantly share code, notes, and snippets.

@vdelacou
Created June 14, 2018 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdelacou/7cab6528fb5e29d0e32be5aee2a06dec to your computer and use it in GitHub Desktop.
Save vdelacou/7cab6528fb5e29d0e32be5aee2a06dec to your computer and use it in GitHub Desktop.
Change jhipster Logout with Auth0
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