User
The User component displays authenticated user information and provides login/logout functionality.
Usage
<fluid-user></fluid-user>
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
hide-widget | boolean | false | Whether to hide the component |
class-name | string | — | Additional CSS classes |
Display Options
| Attribute | Type | Default | Description |
|---|---|---|---|
show-avatar | boolean | true | Show user avatar |
show-name | boolean | true | Show user name |
show-email | boolean | false | Show user email |
show-logout | boolean | true | Show logout button when authenticated |
login-text | string | 'Sign In' | Text for login button |
logout-text | string | 'Sign Out' | Text for logout button |
Examples
Basic User Display
<fluid-user></fluid-user>
Compact with Avatar Only
<fluid-user show-name="false" show-avatar="true" ></fluid-user>
With Email Display
<fluid-user show-email="true" show-avatar="true" ></fluid-user>
Custom Button Text
<fluid-user login-text="Log In" logout-text="Log Out" ></fluid-user>
JavaScript API
// Get authenticated user const user = window.FairShareSDK.getAuthenticatedUser(); if (user) { console.log('User ID:', user.id); console.log('Name:', user.name); console.log('Email:', user.email); } else { console.log('No user authenticated'); } // Set authentication (typically done after OAuth flow) window.FairShareSDK.setAuthentication({ token: "user-auth-token", user: { id: 123, name: "John Doe", email: "john@example.com" } });
Related
- getAuthenticatedUser — Get authenticated user data
- setAuthentication — Set user authentication