update user ID format in HomePage
This commit is contained in:
parent
56332ec8c0
commit
8f4bbcdafa
1 changed files with 16 additions and 2 deletions
|
@ -79,12 +79,26 @@ function UserLoginLogout() {
|
||||||
const { user, isAuthenticated, loginWithRedirect, logout } = useAuth0();
|
const { user, isAuthenticated, loginWithRedirect, logout } = useAuth0();
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
console.log(user);
|
// NOTE: Users created correctly should have these attributes... but I'm
|
||||||
|
// coding defensively, because third-party integrations are always a
|
||||||
|
// bit of a thing, and I don't want failures to crash us!
|
||||||
const username = user["https://oauth.impress-2020.openneo.net/username"];
|
const username = user["https://oauth.impress-2020.openneo.net/username"];
|
||||||
|
const id = user.sub?.match(/^auth0\|impress-([0-9]+)$/)?.[1];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<Box fontSize="sm">Hi, {username}!</Box>
|
{username && <Box fontSize="sm">Hi, {username}!</Box>}
|
||||||
|
{id && (
|
||||||
|
<Button
|
||||||
|
as="a"
|
||||||
|
href={`https://impress.openneo.net/user/${id}-${username}/closet`}
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
marginLeft="2"
|
||||||
|
>
|
||||||
|
Items
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|
Loading…
Reference in a new issue