node.js - Sails.js Waterlock How to override login action (How to write custom login action) -


i use sails.js , waterlock.

  1. in 1 place, need able authenticate user (say) phone number instead email.
  2. in othe place, shoud have unique pin code authentication field.

i thought there possibility override login/register action custom one, did not find example. how done, can please kindly provide me example(tutorial) of custom realization action sails.js/waterlock login action?

please describe solutions briefly, unfortunately, i'm not experienced understand clues. in advance.

i able override register , login actions in following way:

  /* -------------------------------- signup ---------------------------------*/   /**    * adds new user , logs in first time    * signup works out of box in order custom validation ,    * add fields user had add our own    */   signup: function( req, res){      // perform validation data used before store     var invalid = {};     if( !userservice.validateusername( req.param('username'), invalid ) ||         !userservice.validatepassword( req.param('password'), invalid ) ) {           return res.badrequest( invalid );     }      // autentiacation parameters out     var params = req.allparams();     var auth = {       email: params.email,       password: params.password     };      // remove password data     delete(params.password);      // create user , authentication     user.create(params).exec(function(err,  user){       if(err){         return res.negotiate( err );       }       waterlock.engine.attachauthtouser(auth, user, function(err, ua){         if(err){           res.json(err);         }else{           waterlock.cycle.loginsuccess(req, res, ua);         }       });     });   },    /* -------------------------------- login ---------------------------------*/   /**    * logs in user    */   login: function( req, res ) {     var params = req.allparams();     var auth = {       email: params.email,       password: params.password     };     waterlock.engine.findauth({ email: auth.email }, function(err, user){       if(err){         return res.json(err);       }       if (user) {         if(bcrypt.comparesync(auth.password, user.auth.password)){           waterlock.cycle.loginsuccess(req, res, user);         }else{           waterlock.cycle.loginfailure(req, res, user, {error: 'invalid email or password'});         }       } else {         //todo redirect register         waterlock.cycle.loginfailure(req, res, null, {error: 'user not found'});       }     });   }, 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -