Use Actions to Show Users an Announcement after Logging in (Or Rickroll Them)
Tags: programming, security, webdev
Published: 2022-01-05 18:16:14

#### Learn how to use Auth0 Actions to redirect users to an announcement web page and back to the application.

### <br>

Sooner or later, your application will need to present the user with an important announcement immediately after logging in. It could be about:

- Upcoming maintenance, during which time the application will be unavailable
- Changes to the application that will affect its functionality or the user experience
- Notifications about the user’s account, such as an approaching expiry date or that they are running out of storage space allotted to their account
- Every system administrator’s worst nightmare: an outage

The announcement is important enough to interrupt the usual Login flow with a separate page or screen that requires the user to activate a button, link, or other user interface control before proceeding to the application.

While you can predict some of these announcements (e.g., informing the user that their account is about to expire or is running out of storage space or some other resource), many situations that need these announcements will arise with little or no warning. This includes things that are hard to predict, such as unscheduled downtime.

When surprises like these appear, you shouldn’t make changes to your application just to display an announcement. This is especially true if your application has different versions for different platforms, requiring you to make changes in multiple codebases.

These situations need a way to insert a step into the login process to present the announcement to the user. That’s where Actions can help.

> **Look for the 🛠 emoji if you’d like to skim through the content while focusing on the build and execution steps.**


## Introducing Actions

Actions are Node.js functions that execute when triggered by specific events. They allow you to extend Auth0 beyond what it can do “out of the box” by adding logic to login, user registration, password changes, and other events during authentication and other identity-related processes. 

Instead of coding Actions into your application, you write and store them in the Auth0 dashboard, where they are part of your tenant’s settings. Like Auth0’s [Universal Login](https://auth0.com/docs/login/universal-login) web page and authentication and authorization services, Actions are run by Auth0’s servers.

You write Actions to insert them into *flows*, which are processes that happen when using Auth0. The flows that currently support Actions are:

- **Login:** Takes Actions that execute immediately after the user has logged in and before the ID token is issued.
- **Machine to Machine:** Takes Actions that execute during a [machine-to-machine credentials exchange](https://auth0.com/machine-to-machine), just after the ID token is requested and before it is issued.
- **Pre User Registration:** Takes Actions that execute immediately after a user has provided the information to register for a database or passwordless connection and before that connection is registered with Auth0.
- **Post User Registration:** Takes Actions that execute immediately after a user’s database or passwordless connection is registered with Auth0.
- **Post Change Password:**  Takes Actions that execute immediately after the user changes their password.
- **Send Phone Message:**  Takes Actions that execute immediately after a third-party multi-factor authentication provider is asked to send an authentication message to the user and before the message is sent.

This tutorial covers showing an announcement immediately after login, which involves writing Actions for the Login flow.

[Read more...](https://auth0.com/blog/use-actions-show-users-announcement-after-logging-in-or-rickroll-them/?utm_source=content_synd&utm_medium=sc&utm_campaign=actions)