Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});