authentication.loggedIn¶
authentication.loggedIn
is an event on the Event Bus that occurs after a user has logged in.
Event body¶
none
Example¶
In this example we listen to authentication.loggedIn
event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
storefront.eventBus.on('authentication.loggedIn', () => {
console.log('A user has logged in!')
});
});
Example¶
In this example we use a Message Storage API to retrieve an array of past authentication.loggedIn
events.
useStorefront((storefront) => {
const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');
const pastLoggedInEvents = messageStorageApi.getChannelMessages('authentication.loggedIn');
if (pastLoggedInEvents.length > 0) {
pastLoggedInEvents.forEach(({ body: eventBody }) => {
console.log('perform action on every past event');
});
}
});