What is a flash message in a passport?

I am reading Passport documentation and I would like to know what a flash message is. Googeling this does not give me any corresponding answer.

+5
source share
3 answers

Flash message looks like a temporary variable

But this is basically a temporary session. For example, you want to show the error message only once, it will be available for only one click. in your next route it will disappear

Thus, using a flash message, you can show users error or success messages.

+3
source

To rephrase passport.js documents, Flash messages are combined with route redirection to provide or display status information to the user.

app.post('/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true }) ); 

You basically need them to tell the user that they either failed or got access to some resource.

The following are snippets presented in the docs:

In case of failure

 passport.authenticate('local', { failureFlash: 'Invalid username or password.' }); 

In case of success

 passport.authenticate('local', { successFlash: 'Welcome!' }); 
+3
source

The simplest flash setup uses something like connect-flash . It is basically a messaging system that uses a session for temporary storage.

The main tutorials I used use it for messages such as toast pop-ups. As soon as the user confirms the message, he is cleared of the session.

0
source

Source: https://habr.com/ru/post/1257337/


All Articles