Created
July 27, 2020 18:58
-
-
Save KevinDanikowski/162fce7decf4b234c58dee9ec7daed3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// PROTECTED PAGE | |
import React from 'react' | |
import { Loading } from '../components/QueryHandling' | |
import { useAuth } from '../lib/UserContext' | |
export default function ProtectedPage() { | |
const { user } = useAuth(true) | |
if (!user) { | |
return <Loading /> | |
} | |
return ( | |
<> | |
... | |
</> | |
) | |
} |
This file contains hidden or 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
// UNPROTECTED PAGE | |
import React from 'react' | |
import { useAuth } from '../lib/UserContext' | |
export default function ProtectedPage() { | |
const { user } = useAuth(true) | |
const userEmail = user ? user.signInUserSession.idToken.payload.email : '' | |
return ( | |
<> | |
<div>Email: {userEmail}</div> | |
... | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment