Skip to content

Commit

Permalink
feat: auth0 get token
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelVallenet committed May 15, 2023
1 parent 23b9faa commit 111aa83
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions web/src/components/ProtectedRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ import { useDispatch, useSelector } from "react-redux";
import { Dimmer } from "tabler-react";
import { useAuth0 } from "@auth0/auth0-react";


//TODO: update redux state with isAuthenticated value
//TODO: dispatch action to update redux state with userSession
//TODO: Then if userSession.isAuthenticated is true & userSession.accesToken is set, render the component
const ProtectedRoute = ({ component: Component, ...rest }) => {
const dispatch = useDispatch();
const userSession = useSelector(state => state.userSession);
const { isLoading, isAuthenticated, loginWithRedirect, getIdTokenClaims } = useAuth0()
const { isLoading, isAuthenticated, loginWithRedirect, getAccessTokenSilently } = useAuth0()

if (!isLoading && !isAuthenticated) {
loginWithRedirect();
} else if (!isLoading && isAuthenticated) {
getIdTokenClaims().then((claims) => {
console.log(claims.__raw);
getAccessTokenSilently().then((token) => {
console.log(token.__raw);
});
}
// useEffect(() => {
Expand Down

0 comments on commit 111aa83

Please sign in to comment.