mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 21:29:08 +03:00
* feat: user impersonation * refactor * add anon impersonation * add user impersonation to graphiql * thanks Ivan for this one * add radio buttons * progress * working user selector * adds loading and error states to user selector * nicer popover button * default graphiql to use service role key * styling updates * fix padding in graphiql * add service role warning to graphiql * add user impersonation to realtime inspector * add feature flag * use Alert_Shadcn_ instead of old Alert * Update apps/studio/lib/role-impersonation.ts Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * update title * Update apps/studio/components/interfaces/RoleImpersonationSelector/UserImpersonationSelector.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Update apps/studio/components/interfaces/RoleImpersonationSelector/Icons.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Update apps/studio/components/interfaces/RoleImpersonationSelector/Icons.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Update apps/studio/components/interfaces/RoleImpersonationSelector/Icons.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Update apps/studio/components/interfaces/RoleImpersonationSelector/Icons.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Update apps/studio/components/interfaces/RoleImpersonationSelector/Icons.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Update apps/studio/components/interfaces/RoleImpersonationSelector/UserImpersonationSelector.tsx Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * add constant padding at the bottom of user selector * update graphiql buttons font size * make rls warning dismissable * use text-foreground on rls warning title * fix no results while impersonating a role * fix error line number when impersonating a role --------- Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import { User } from 'data/auth/users-query'
|
|
|
|
export function getDisplayName(user: User, fallback = '-'): string {
|
|
const {
|
|
displayName,
|
|
display_name,
|
|
fullName,
|
|
full_name,
|
|
familyName,
|
|
family_name,
|
|
givenName,
|
|
given_name,
|
|
surname,
|
|
lastName,
|
|
last_name,
|
|
firstName,
|
|
first_name,
|
|
} = user.raw_user_meta_data ?? {}
|
|
|
|
const last = familyName || family_name || surname || lastName || last_name
|
|
const first = givenName || given_name || firstName || first_name
|
|
|
|
return (
|
|
displayName ||
|
|
display_name ||
|
|
fullName ||
|
|
full_name ||
|
|
(first && last && `${first} ${last}`) ||
|
|
fallback
|
|
)
|
|
}
|
|
|
|
export function getAvatarUrl(user: User): string | undefined {
|
|
const {
|
|
avatarUrl,
|
|
avatarURL,
|
|
avatar_url,
|
|
profileUrl,
|
|
profileURL,
|
|
profile_url,
|
|
profileImage,
|
|
profile_image,
|
|
profileImageUrl,
|
|
profileImageURL,
|
|
profile_image_url,
|
|
} = user.raw_user_meta_data ?? {}
|
|
|
|
return (
|
|
avatarUrl ||
|
|
avatarURL ||
|
|
avatar_url ||
|
|
profileImage ||
|
|
profile_image ||
|
|
profileUrl ||
|
|
profileURL ||
|
|
profile_url ||
|
|
profileImageUrl ||
|
|
profileImageURL ||
|
|
profile_image_url
|
|
)
|
|
}
|