For the following snippets to work as intended you will need to add a fliplet-session library to your app. Use the following instructions to add it

  1. When in Fliplet Studio’s Edit screen, open the Developer Options from the right hand menu
  2. With the Developer Options open, click the Libraries button in the top right corner
  3. In the search field, type in ‘fliplet-session’
  4. Click it to add it to the list
  5. Click Save

When a user logs out a typical requirement would be to take them out of the app and display the login screen. Similarly, once a user logs in you may want to display additional menu options that they can now access.

On login

If you’re using a login component (with username and password entry that doesn’t require verification) then you can add the following hook to run when a user logs in. The example takes the user to another screen (with ID ‘123456’) once it detects they’ve logged in.

Fliplet.Hooks.on('login', function (entry) {

If you’re logging in with the email and SMS verification components then you will need to use a slightly different hook:

Fliplet.Hooks.on('onUserVerified', function (entry) {

On logout

To run an action on logout you can run your custom code at the same time you programmatically log a user out. For example, the following code logs a user out and then redirects them to another screen (with a screen ID of 85764).

  .then(function () {
    // add custom code here to be run after log out
    // below we navigate a user to a new screen

In the code above, we’ve logged the user out from the dataSource passport. This assumes that they logged in using the ‘Login’, ‘Verification: Email’ or ‘Verification: SMS’ components (that use a data source). However, if a user has logged in with a ‘SAML2 Login’ or a ‘Fliplet Login’ component then you’ll need to change the code slightly.

  .then(function () {
    // Logs out a user that logged in with a SAML2 Login component      

  .then(function () {
    // Logs out a user that logged in with a Fliplet Login component      
Was this article helpful?