To make this work with User.query
, I changed your adapter.js
file a little, I don't know if it is the right way of doing this
I changed query: query
to something like
query: function(collectionName, q, params, cb){
query(q, params, cb, true);
},
It would be great if attributes checks like the following could be used: (for example the following attributes work with other database adapters out there)
attributes: {
username: {
type: "string",
required: true,
},
name: {
type: "string",
required: true
},
password: {
type: "string",
required: true
},
email: {
type: "string",
email: true,
required: true,
}
}
For example while registering a user, it would be nice to have a required:true
, giving errors for empty fields
I am having problems getting data from the database, but it is adding data correctly. I am using sails normal findOne method
login: function (req, res) {
// Try to look up user using the provided email address
User.findOne({
email: req.param('email')
}, function foundUser(err, user) {
if (err) return res.negotiate(err);
if (!user) return res.notFound();
// Compare password attempt from the form params to the encrypted password
// from the database (`user.password`)
require('machinepack-passwords').checkPassword({
passwordAttempt: req.param('password'),
encryptedPassword: user.encryptedPassword
}).exec({
error: function (err){
return res.negotiate(err);
},
// If the password from the form params doesn't checkout w/ the encrypted
// password from the database...
incorrect: function (){
return res.notFound();
},
success: function (){
// Store user id in the user session
req.session.me = user.id;
// All done- let the client know that everything worked.
return res.ok();
}
});
});
}
But it does not seem to be getting any data