Skip to content

Instantly share code, notes, and snippets.

@blogcacanid
Created November 11, 2020 23:52
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 blogcacanid/84eed40368afb0946d866b343369a58d to your computer and use it in GitHub Desktop.
Save blogcacanid/84eed40368afb0946d866b343369a58d to your computer and use it in GitHub Desktop.
Profile.js Authentication JWT React JS Lumen 7
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