Get User

Retrieve the currently authenticated user's information.

Usage

Copy
const user = await Loby.getUser()

Returns the current user object if signed in, or null if not authenticated.

Return Value

When a user is signed in, getUser() returns an object with user information:

Copy
{ id: "abc123", firstName: "John", lastName: "Doe", email: "john@example.com" // Additional fields may be available }

Example: Check Sign-In Status on Page Load

Copy
window.lobyAsyncInit = async function() { await Loby.init({ clientId: 1234, version: 'v1' }) // Check if user is already signed in const user = await Loby.getUser() if (user) { console.log('User is signed in:', user.firstName) showUserDashboard(user) } else { console.log('No user signed in') showSignInButton() } }

Example: Display User Information

Copy
<div id="user-info"></div> <script> async function displayUser() { const user = await Loby.getUser() if (user) { document.getElementById('user-info').innerHTML = ` <p>Welcome, ${user.firstName} ${user.lastName}!</p> <p>Email: ${user.email}</p> ` } } </script>

Example: Conditional Content

Copy
async function showMemberContent() { const user = await Loby.getUser() if (!user) { // Not signed in - show sign-in prompt document.getElementById('content').innerHTML = ` <p>Please sign in to view member content.</p> <button onclick="Loby.showSignIn()">Sign In</button> ` return } // User is signed in - show member content document.getElementById('content').innerHTML = ` <p>Welcome back, ${user.firstName}!</p> <!-- Member-only content here --> ` }
Previous
Sign Out
Next
Memberships