how to display flash message in html view for nodejs
<p>this function is for login authentication.i want to display alert message in browser when authentication failed.i cant use alert because in node alert is not defined so i am trying to use flash for display alert message.how can i use it please suggest if there is any other method to do this.</p>

<pre><code>login : function(req, res) {
        var sess;
        sess = req.session;
        sess.user = req.body.username;
        if (sess.user) {

            /*
             * This line check Session existence. If it existed will do some
             * action.
             */
            var db = req.app.get('db')();
            // console.log(db);
            var Username = req.body.username;
            var Password = req.body.password;
            console.log('u r here');

            if (!Username.trim())
            {
                console.log('Incorrect username');
                // res.end('Incorrect username');
                res.redirect('/login');
            }
            else if (!Password.trim())
            {
                console.log('Incorrect Password');
                // res.end('Incorrect Password');
                res.redirect('/login');
            }
            else
            {
                var queryString = 'SELECT * from admin_info where user_name= ? And password=?';
                console.log(queryString);
                db.query(queryString, [ Username, Password ], function(error, rows, fields) 
                {
                    if (error) 
                    {
                        console.log(error);
                        res.end(error);
                    } 
                    else 
                    {
                        console.log('u r in function');
//                      console.log(Username + " " + Password);
        //              console.log(rows[0].id);
                        if(rows.length&gt;0)
                        req.session.user_type_id=rows[0].user_type_id;
//                      req.session.userName =rows[0].username;
                        if (rows.length &gt; 0) {
                            var str = '';

                            for (var i = 0; i &lt; rows.length; i++) {
                                str = str + rows[i].Username + '\n';
                            }

                            module.exports.user(req,res);

                        } else {
                            // dialog.info('invalid username or password');
                            // res.end('Invalid username or password');
                            // res.redirect('/login');
                            res.render('login', { messages: req.flash('info','hello') });

                        }
                    }

                });

            }
        } else {
            res.redirect('/login');
        }

    },
</code></pre>