Skip to main content

Listen to User Events

After signing in a user, you can subscribe to listen to specific user events and get notified when such an event happens through the onUserEvent method. You can listen to the following user events.

EventDescription
user:signinTriggered whenever a new user session is created.
user:signoutTriggered when a user session is deleted. If signOutAll or signOutAllExceptCurrent method is called then for each deleted sesssion a separate user:signout event is triggered.
user:updateTriggered whenever user data changes including password, email and phone number updates.
user:deleteTriggered when the user data is deleted from the database.
user:pwdchangeTriggered when the user password changes, either through direct password update or password reset.
user:emailchangeTriggered whenever the email of the user changes.
user:phonechangeTriggered whenever the phone number of the user changes.
altogic.auth.onUserEvent((eventName, session) =>
console.log('User event', eventName, session)
);
note

Please note that user:update and user:delete events are fired only when a specific user with a known _id is updated or deleted in the database. For bulk user update or delete operations these events are not fired.

An active user session is required (e.g., user needs to be logged in) to call this method.

Parameters

Here you can find parameters for the onUserEvent method.

#

Name

Data type

Required

Description

1listenerFunctionYesThe listener function. This function gets two input parameters the name of the event that is being triggered and the user session object that has triggered the event. If the event is triggered by the user without a session, then the session value will be null.