Skip to content

Instantly share code, notes, and snippets.

@aaishikasb
Created January 13, 2022 07:22
Show Gist options
  • Save aaishikasb/6fd2bb9c5af5ffa66b75c8249ea2b748 to your computer and use it in GitHub Desktop.
Save aaishikasb/6fd2bb9c5af5ffa66b75c8249ea2b748 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import auth0Client from './Auth';
class Home extends Component {
componentDidMount() {
if (!auth0Client.isAuthenticated()) {
auth0Client.signIn();
}
}
signOut = () => {
auth0Client.signOut();
this.props.history.replace('/');
}
render() {
return (
<div className="App" >
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
{
auth0Client.isAuthenticated() &&
<div>
<label className="mr-2 text-white">{auth0Client.getProfile().name}</label>
<br />
<button className="btn btn-dark" onClick={() => { this.signOut() }}>Sign Out</button>
</div>
}
</header>
</div>
)
}
}
export default Home;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment