Created
January 13, 2022 07:22
-
-
Save aaishikasb/6fd2bb9c5af5ffa66b75c8249ea2b748 to your computer and use it in GitHub Desktop.
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 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