How to use the leanengine.User function in leanengine

To help you get started, we’ve selected a few leanengine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leancloud / leanengine-nodejs-demos / routes / users.js View on Github external
router.post('/register', function(req, res, next) {
  var username = req.body.username;
  var password = req.body.password;
  if (!username || username.trim().length == 0
    || !password || password.trim().length == 0) {
    return res.redirect('/users/register?errMsg=用户名或密码不能为空');
  }
  var user = new AV.User();
  user.set('username', username);
  user.set('password', password);
  user.signUp().then(function(user) {
    res.saveCurrentUser(user);
    res.redirect('/todos');
  }, function(err) {
    res.redirect('/users/register?errMsg=' + err.message);
  }).catch(next);
});