Skip to content

Commit

Permalink
[FIX] admin-ui displayed logged user
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxxx873 committed Feb 27, 2024
1 parent e897507 commit eaf5eff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Domain from "./pages/domain/Domain";
import Account from "./pages/account/Account";
import Docs from "./pages/docs/Docs";
import { useAuth } from "react-oidc-context";
import { useEffect, useState } from 'react';

function App() {
const auth = useAuth();
Expand Down
4 changes: 3 additions & 1 deletion admin-ui/src/componetns/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import "./navbar.scss"
import { useAuth } from "react-oidc-context";

const Navbar = () => {
const auth = useAuth();
return (
<div className="navbar">
<div className="logo">
Expand All @@ -17,7 +19,7 @@ const Navbar = () => {
</div>
<div className="user">
<img src="user.png" alt="user" className="icon" />
<span>Admin</span>
{<span>{auth.user?.profile.preferred_username}</span>}
</div>
<img src="settings.svg" alt="settings" className="icon" />
</div>
Expand Down
3 changes: 2 additions & 1 deletion admin-ui/src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useAuth } from "react-oidc-context";

const Login = () => {
const auth = useAuth();
console.log("user:", auth.user?.profile);
const onButtonClick = () => {
auth.signinRedirect();
}
Expand All @@ -21,7 +22,7 @@ const Login = () => {
onClick={onButtonClick}
value={auth.isAuthenticated ? 'Log out' : 'Log in'}
/>
{auth.isAuthenticated ? <div>You logged as {auth.user?.profile.name}</div> : <div />}
{auth.isAuthenticated ? <div>You logged as {auth.user?.profile.preferred_username}</div> : <div />}
</div>
</div>
)
Expand Down

0 comments on commit eaf5eff

Please sign in to comment.