Skip to content

Commit

Permalink
Add keycloak actions to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
soerface committed Nov 17, 2024
1 parent 60c13af commit 2204358
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/NavBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
padding: 0;
user-select: none;
width: 10em;
z-index: 1;
}

.navbar ul.nav-links > li > * {
Expand All @@ -77,6 +78,15 @@
.navbar ul.nav-links li ul button {
width: 100%;
margin: 0.3em 0;
text-align: right;
background: none;
border: none;
border-right: 5px solid rgba(0, 0, 0, 0);
border-radius: 0;
}

.navbar ul.nav-links li ul button:hover {
border-right: 5px solid #fff;
}

.navbar ul.nav-links li > .title::after {
Expand Down
22 changes: 20 additions & 2 deletions src/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,32 @@ import {useAuth} from "react-oidc-context";

function NavBar() {
const auth = useAuth();
const loginButton = <button className="login-button" onClick={() => auth.signinRedirect()}>Login</button>
const loginButton = <button className="login-button" onClick={() => auth.signinRedirect()}>Anmelden</button>
const userMenu = <>
<span className="title" style={{
lineHeight: "1.1em",
overflow: "hidden",
textAlign: "right",
}}>{auth.user?.profile.preferred_username}</span>
<ul>
<li>
<button onClick={() => {
auth.signinRedirect({
extraQueryParams: {
kc_action: "UPDATE_PROFILE",
}
})
}}>Profil aktualisieren
</button>
<button onClick={() => {
auth.signinRedirect({
extraQueryParams: {
kc_action: "UPDATE_PASSWORD",
}
})
}}>Passwort ändern
</button>
</li>
<li>
<button onClick={async () => {
await auth.revokeTokens();
Expand All @@ -22,7 +40,7 @@ function NavBar() {
// in other parts of the application.
// Therefore, let's just reload the application
window.location.reload()
}}>Logout
}}>Abmelden
</button>
</li>
</ul>
Expand Down

0 comments on commit 2204358

Please sign in to comment.