davidrivera/waterlock — pull request #24 by Karnith (2014-08-19 19:39:14+00:00)
Title: changed null to user.id

changed null to user.id so auth can be created for new users after first user is created.

example create route taking params from registration from:

```sh
create: function(req, res, next) {
var auth = {
email: req.param('email'),
password: req.param('password')
},
userObj = {
name: req.param('name'),
title: req.param('title'),
email: req.param('email')
};

User.create(userObj)
.exec(function (err, user){
if (err){
sails.log.error(err);
req.session.flash = {
err: err
};

return res.redirect('/user/new');
}
req.session.user = user;

user.online = true;
req.session.authenticated = true;
user.save(function(err, user) {
if(err) {
sails.log.error(err);
return next(err);
}

user.action = " signed-up and logged-in.";

User.publishCreate(user);
waterlock.engine.attachAuthToUser(auth, user, function (err) {
if (err) {
sails.log.error(err);
res.json(err);
}
else {
waterlock.logger.debug('user login success');
return res.redirect('/user/show/'+user.id);
}
});
});
});
}
```