Skip to content

Authentication

Shodiqul Muzaki edited this page Jan 14, 2016 · 2 revisions

Login

var ModelUser = db.collection('users');
var data = {
 username : 'user',
 password : 'password'
}

req.cermai.login(ModelUser, data, req, function(err, result) {
 if (result == true) {
  // DO SOMETHING WHEN LOGIN SUCCESS //
 }
 else {
  // DO SOMETHING WHE LOGIN FAILED //
 }
})
  • ** data ** : contains the username and password that you want matched to the database
  • ** username ** : check for matching username
  • ** password ** : check for matching password
  • ** ModelUser ** : collections on database mongodb

Check Authentication

add midleware on your handler example code

cermai.get('/main', cermai.isAuth, Welcome.index);

Logout

req.cermai.logout(req,res, urlToRedirect);

Clone this wiki locally