MCPcopy Create free account
hub / github.com/ShipSecAI/studio / UserButton

Function UserButton

frontend/src/components/auth/UserButton.tsx:24–187  ·  view source on GitHub ↗
({
  afterSignOutUrl = '/',
  appearance,
  showUserInfo = true,
  className = '',
  sidebarCollapsed = false,
})

Source from the content-addressed store, hash-verified

22}
23
24export const UserButton: React.FC<UserButtonProps> = ({
25 afterSignOutUrl = '/',
26 appearance,
27 showUserInfo = true,
28 className = '',
29 sidebarCollapsed = false,
30}) => {
31 const authProvider = useAuthProvider();
32 const { user, isAuthenticated, isLoading } = authProvider.context;
33
34 // Handle loading state
35 if (isLoading) {
36 return (
37 <Button variant="ghost" size="sm" disabled className={className}>
38 <div className="animate-pulse flex items-center space-x-2">
39 <div className="w-6 h-6 bg-muted rounded-full"></div>
40 <div className="w-16 h-4 bg-muted rounded"></div>
41 </div>
42 </Button>
43 );
44 }
45
46 // If not authenticated, show sign in button
47 if (!isAuthenticated || !user) {
48 return (
49 <Button variant="outline" size="sm" onClick={authProvider.signIn} className={className}>
50 <User className="w-4 h-4 mr-2" />
51 Sign In
52 </Button>
53 );
54 }
55
56 // Use Clerk's UserButton if available
57 if (authProvider.name === 'clerk') {
58 const ClerkUserButton = authProvider.UserButtonComponent;
59 return (
60 <div className={`flex items-center ${className}`}>
61 <ClerkUserButton
62 afterSignOutUrl={afterSignOutUrl}
63 appearance={{
64 elements: {
65 avatarBox: sidebarCollapsed ? 'w-8 h-8' : 'w-8 h-8',
66 userButtonTrigger: sidebarCollapsed ? 'w-8 h-8' : 'w-full',
67 ...appearance?.elements,
68 },
69 ...appearance,
70 }}
71 />
72 </div>
73 );
74 }
75
76 // Fallback custom user button for other providers
77 const userInitials =
78 user.firstName && user.lastName
79 ? `${user.firstName[0]}${user.lastName[0]}`
80 : user.username
81 ? user.username.substring(0, 2).toUpperCase()

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
useAuthProviderFunction · 0.85

Tested by

no test coverage detected