{Skin/Usermenu.htmlload}
Beverly Hills Real Estate

Main Content

Moving From To Florida


   (Go Back) Choose State To Move From ') {
// console.log('no user!');
res.redirect('/login');
} else {
// console.log('user detected');
next();
}
}

app.get('/', function(req, res) {
res.render('index', { title: 'Express' });
});

app.get('/login', function(req, res) {
res.render('login.ejs', { title: 'Express' });
});

app.post('/login', function(req, res) {
var username = req.body.username;
var password = req.body.password;
if (username.length > 0 && password.length > 0) {
User.findOne({ username: username }, function(err, user) {
if (err) {
console.log(err);
res.redirect('/login');
}
if (user) {
console.log(user);
if (user.password === password) {
// console.log('password match');
req.session.user = user;
res.redirect('/success');
} else {
res.redirect('/login');
}
} else {
res.redirect('/login');
}
});
} else {
res.redirect('/login');
}
});

app.get('/success', checkAuth, function(req, res) {
res.render('success.ejs', { title: 'Express' });
});

app.get('/logout', function(req, res) {
req.session.destroy();
res.redirect('/login');
});

app.get('/register', function(req, res) {
res.render('register.ejs', { title: 'Express' });
});

app.post('/register', function(req, res) {
var username = req.body.username;
var password = req.body.password;
if (username.length > 0 && password.length > 0) {
User.findOne({ username: username }, function(err, user) {
if (err) {
console.log(err);
res.redirect('/register');
}
if (user) {
// console.log('username already exists');
res.redirect('/register');
} else {
var newUser = new User({
username: username,
password: password
});
newUser.save(function(err, user) {
if (err) {
console.log(err);
res.redirect('/register');
} else {
console.log('user created');
req.session.user = user;
res.redirect('/success');
}
});
}
});
} else {
res.redirect('/register');
}
});

module.exports = app;

Let's work together
Thank you for your interest in getting in touch with me. Please select the option that suits you the best and fill out the form: