Created
November 11, 2020 23:52
-
-
Save blogcacanid/84eed40368afb0946d866b343369a58d to your computer and use it in GitHub Desktop.
Profile.js Authentication JWT React JS Lumen 7
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 from "react"; | |
import { Redirect } from 'react-router-dom'; | |
import { useSelector } from "react-redux"; | |
const Profile = () => { | |
const { user: currentUser } = useSelector((state) => state.auth); | |
if (!currentUser) { | |
return <Redirect to="/login" />; | |
} | |
return ( | |
<div className="container"> | |
<header className="jumbotron"> | |
<h3>Profile</h3> | |
<h3> | |
<strong>{currentUser.username}</strong> | |
</h3> | |
<p> | |
<strong>Id:</strong> {currentUser.id} | |
</p> | |
<p> | |
<strong>Email:</strong> {currentUser.email} | |
</p> | |
<p> | |
<strong>Token:</strong> {currentUser.accessToken.substring(0, 20)} ...{" "} | |
{currentUser.accessToken.substr(currentUser.accessToken.length - 20)} | |
</p> | |
</header> | |
</div> | |
); | |
}; | |
export default Profile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment