-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Indicate logged-in-user-email in Navigation bar.
- Conditional rendering of username in Navigation.tsx. - New custom react hook, useLoggedInUser. Signed-off-by: Nkeiruka <[email protected]>
- Loading branch information
Showing
2 changed files
with
44 additions
and
4 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,21 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useSettings } from "./useSettings"; | ||
import { fetchIdentity } from "api/auth-identities"; | ||
import { queryKeys } from "util/queryKeys"; | ||
|
||
export const useLoggedInUser = () => { | ||
const { data: settings } = useSettings(); | ||
|
||
const id = settings?.auth_user_name; | ||
const authMethod = settings?.auth_user_method; | ||
|
||
const { data: identity } = useQuery({ | ||
queryKey: [queryKeys.identities, id], | ||
queryFn: () => fetchIdentity(id!, authMethod!), | ||
}); | ||
|
||
return { | ||
loggedInUserName: identity?.name || id, //this should only return the username cross referenced by the auth username | ||
authMethod, //If connected via TLS, then display "Connected via TLS, else render username" | ||
}; | ||
}; |