function loginLocal(req, res) {
//    console.log('loginLocal called');
//    res.writeHead(302, {'Location': '/dashboard', 'Content-Type': 'text/plain; charset=utf-8'});
//    res.write('Redirecting.......');
//    res.end();
    var form = new formidable.IncomingForm();
    form.parse(req, function (err, fields, files) {
        // Need to set cookies on my own. For now I will test using hardocded users and hardocded cookie
        userVerification(fields.useremail, fields.userpassword, function(err, sessionCookie) {
            console.log('Login returned', sessionCookie);
            if(sessionCookie) {
                console.log("Login successful with sessionCookie : " + sessionCookie);
                // Set the cookie in the client's browser
                // Two cookies : email, session
    //            keys = keygrip([ process.env.COOKIESECRET1 || "COOKIESECRET1", process.env.COOKIESECRET2 || "COOKIESECRET2" ], 'sha256', 'hex');
                // Moved keys to top
    //            console.log(keys);
                var cookies = new Cookies( req, res, keys);

                // setting email cookie
                cookies.set( "email", fields.useremail, { signed: true } );

                // setting session cookie
                cookies.set( "session", sessionCookie, { signed: true } );

                // Redirect the user then
                res.writeHead(302, {'Location': '/dashboard'});
//                return res.end();
                res.end();
            } else {
                console.log("Login failed with cookie : " + sessionCookie);
                res.writeHead(302, {'Location': '/index/?email=' + fields.useremail});
                res.end();
            }
//            res.end(util.inspect({fields: fields}));
        });
    });
}
// Local login using emailId and password combination
Local login using emailId and password combination
Local login using emailId and password combination
function loginLocal(req, res) {
    var form = new formidable.IncomingForm();
    form.parse(req, function (err, fields, files) {
        userVerification(fields.useremail, fields.userpassword, function(err, sessionCookie) {
            console.log('Login returned', sessionCookie);
            if(sessionCookie) {
                console.log("Login successful with sessionCookie : " + sessionCookie);
                var cookies = new Cookies( req, res, keys);
                cookies.set( "email", fields.useremail, { signed: true } );
                cookies.set( "session", sessionCookie, { signed: true } );
                res.writeHead(302, {'Location': '/dashboard'});
                res.end();
            } else {
                console.log("Login failed with cookie : " + sessionCookie);
                res.writeHead(302, {'Location': '/index/?email=' + fields.useremail});
                res.end();
            }
        });
    });
}
function loginLocal ( req , res ) { var form = new formidable . IncomingForm ( ) ; form . parse ( req , function ( err , fields , files ) { userVerification ( fields . useremail , fields . userpassword , function ( err , sessionCookie ) { console . log ( 'Login returned' , sessionCookie ) ; if ( sessionCookie ) { console . log ( "Login successful with sessionCookie : " + sessionCookie ) ; var cookies = new Cookies ( req , res , keys ) ; cookies . set ( "email" , fields . useremail , { signed : true } ) ; cookies . set ( "session" , sessionCookie , { signed : true } ) ; res . writeHead ( 302 , { 'Location' : '/dashboard' } ) ; res . end ( ) ; } else { console . log ( "Login failed with cookie : " + sessionCookie ) ; res . writeHead ( 302 , { 'Location' : '/index/?email=' + fields . useremail } ) ; res . end ( ) ; } } ) ; } ) ; }
Local login using emailId and password combination
Local login using emailId and password combination
//    console.log('loginLocal called'); //    res.writeHead(302, {'Location': '/dashboard', 'Content-Type': 'text/plain; charset=utf-8'}); //    res.write('Redirecting.......'); //    res.end(); // Need to set cookies on my own. For now I will test using hardocded users and hardocded cookie // Set the cookie in the client's browser // Two cookies : email, session //            keys = keygrip([ process.env.COOKIESECRET1 || "COOKIESECRET1", process.env.COOKIESECRET2 || "COOKIESECRET2" ], 'sha256', 'hex'); // Moved keys to top //            console.log(keys); // setting email cookie // setting session cookie // Redirect the user then //                return res.end(); //            res.end(util.inspect({fields: fields}));