PelcroUserLoggedIn
Fired when user logs in
Overview
Fired when a user successfully authenticates via any login method. This is the primary event for detecting user login.
Triggered By
| Method | Login Type |
|---|---|
Pelcro.user.login() | email |
Pelcro.user.idpLogin() | IDP |
Pelcro.user.authenticate() | email |
Event Detail
The event.detail object contains the full user object plus a loginType field:
| Property | Type | Description |
|---|---|---|
loginType | string | How the user logged in: "email" or "IDP" |
id | number | User's unique identifier |
email | string | User's email address |
first_name | string | User's first name |
last_name | string | User's last name |
auth_token | string | JWT authentication token |
subscriptions | array | User's active subscriptions |
memberships | array | User's memberships |
addresses | array | User's saved addresses |
orders | array | User's order history |
Example
document.addEventListener('PelcroUserLoggedIn', (event) => {
const user = event.detail;
console.log(`Welcome back, ${user.first_name}!`);
console.log(`Login method: ${user.loginType}`);
// Check subscription status
if (user.subscriptions?.length > 0) {
console.log('User has active subscriptions');
unlockPremiumContent();
}
// Track login in analytics
analytics.track('User Logged In', {
method: user.loginType,
userId: user.id
});
});Login Type Values
| Value | Description |
|---|---|
email | Standard email/password login |
IDP | Identity provider (SSO) login via idpLogin() |
Related Events
This event is often fired alongside:
- PelcroUserLoaded - Always fires with user data
Related
- Events Overview - All available events
- User Module - Methods that trigger this event
Updated 1 day ago
