Skip to content

authentication.unauthorized

authentication.unauthorized is an event on the Event Bus that occurs after a user has unauthorized.

Event body

none

Example

In this example we listen to authentication.unauthorized event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    storefront.eventBus.on('authentication.unauthorized', () => {
        console.log('A user has unauthorized!')
    });
});

Example

In this example we use a Message Storage API to retrieve an array of past authentication.unauthorized events.

useStorefront((storefront) => {
    const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');

    const pastUnauthorizedEvents = messageStorageApi.getChannelMessages('authentication.unauthorized');

    if (pastUnauthorizedEvents.length > 0) {
        pastUnauthorizedEvents.forEach(({ body: eventBody }) => {
            console.log('perform action on every past event');
        });
    }
});

JS API reference