Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8985895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:25:33+00:00 2026-06-15T21:25:33+00:00

After upgrading to Express 3 I went through the joys of implementing connect-flash and

  • 0

After upgrading to Express 3 I went through the “joys” of implementing connect-flash and have it working.

I implement like this:

var flash = require('connect-flash');

app.use(flash());

app.use( function (req, res, next) {
    res.locals.everyauth.user = req.user;
    res.locals.user = req.user;
    res.locals.flash = req.flash();
    next();
});

I display the flash alerts in my jade layout template (used by all pages, and have a similar line for flash.info, flash.warning, etc) like this:

- if ('undefined' !== typeof flash.error && flash.error.length)
    - each msg in flash.error
        div.error= msg

All is well EXCEPT when I render my /login and /register pages via express, when I get a “flash is not defined” error. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:25:35+00:00Added an answer on June 15, 2026 at 9:25 pm

    Well, it’s not pretty, but I’ve found a workaround for this. Basically, I’ve added the first if statement to the block in my express template that handles the flash messages:

    - if (flash !== null)
        - if ('undefined' !== typeof flash.error && flash.error.length)
            - each msg in flash.error
                div.error= msg
    
        - if ('undefined' !== typeof flash.warning && flash.warning.length)
            - each msg in flash.warning
                div.warning= msg
    
        - if ('undefined' !== typeof flash.info && flash.info.length)
            - each msg in flash.info
                div.info= msg
    
        - if ('undefined' !== typeof flash.success && flash.success.length)
            - each msg in flash.success
                div.success= msg
    

    Then, I added a local variable in everyauth’s page rendering statement that sets flash to null, like this (you’ll need one for the register and login pages):

    .registerView('register.jade')
        .registerLocals({
            title: 'Hi there, I am a register page',
            flash: null
        })
    

    Like I said, it ain’t pretty, but it seems to be working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are getting this error after upgrading to NHibernate 2.1. [QueryException: Cannot simultaneously fetch
After upgrading to Django 1.2 I have strange urls in my administration panel. They
I have just discovered that after upgrading to the latest Xcode 3.2.2, I am
After upgrading WordPress, TinyMCE Excerpt stopped working, and so did the excerpt code within
After upgrading to rails 2.3.5 I got things working again and the tests were
After upgrading Xcode to the 4.2, I'm going through and fixing all the new
After upgrading working folder from svn 1.6 to 1.7, all projects are linked to
I have a problem after upgrading to version 4.2.1. when i try to do
I have problems after upgrading: jqGrid from 3.5.3 to 3.8.2 jquery from 1.3.2 to
After upgrading to the newest GWT/Google app engine I have problems opening my workspace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.