I am using Locomotivejs and passportJS for auth on a project, and I found some code online to handle register:
AccountController.create = function() {
var account = new Account();
console.log("test");
account.email = this.param('email');
account.password = this.param('password');
account.name.first = this.param('first');
account.name.last = this.param('name.last');
var self = this;
account.save(function (err) {
if (err) {
console.log(err);
return self.redirect(self.urlFor({ action: 'new' }));
}
return self.redirect(self.urlFor({ action: 'login' }));
});
};
However I cannot figure out how to display error messages on the page such as "Username already exists" or "passwords do not match" etc. I can only get them to console.log(). Does anyone know how I can do this?