-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
403 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useAuth } from "react-oidc-context" | ||
// import { UserManager } from "oidc-client-ts"; | ||
import { Button } from "@mui/material"; | ||
import log from "loglevel" | ||
|
||
export default function Test(){ | ||
|
||
const auth = useAuth(); | ||
// const mng = new UserManager({ popup_redirect_uri: "http://localhost:3000"}); | ||
log.warn("AUTH", auth) | ||
// log.warn("MGN: ", mng) | ||
log.warn("USER", auth?.user) | ||
|
||
|
||
switch (auth.activeNavigator) { | ||
case "signinSilent": | ||
return <div>Signing you in...</div>; | ||
case "signoutRedirect": | ||
return <div>Signing you out...</div>; | ||
} | ||
|
||
|
||
if (auth.isLoading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
if (auth.error) { | ||
return <div>Oops... {auth.error.message}</div>; | ||
} | ||
|
||
if (auth.isAuthenticated) { | ||
return ( | ||
<> | ||
Hello {auth.user?.profile.preferred_username} | ||
<Button onClick={() => void auth.removeUser()}>Log out</Button> | ||
</> | ||
); | ||
} | ||
|
||
return( | ||
<> | ||
<Button onClick={() => void auth.signinRedirect()}>Log in</Button> | ||
<Button | ||
onClick={() => void auth.signinRedirect()}>Sign Up</Button> | ||
</> | ||
|
||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const oidcConfig = { | ||
authority: 'https://dev-k8s.treetracker.org/keycloak/realms/treetracker/', | ||
client_id: 'raw-client', | ||
redirect_uri: 'http://localhost:3000/', | ||
realm: 'treetracker', | ||
onSigninCallback: (res) => { | ||
console.log('onSigninCallback', res); | ||
localStorage.setItem('res', JSON.stringify(res)); | ||
}, | ||
// to oidcConfig to remove the payload from the URL upon successful login, | ||
}; | ||
|
||
export default oidcConfig |
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
Oops, something went wrong.