You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to define an instance method and class method and am receiving a TypeError indicating that the methods are not defined. I am not sure what I have defined incorrectly.
Any insight is appreciated. Great library by the way!!
Below is the model definition and invocation. The error I get is
** Error Getting User: TypeError: undefined is not a function
When i try to call if (!user.authenticate(password)) ....
Here is the definition:
/* jshint indent: 2 */
var crypto = require('crypto');
if (!user) {
return done(null, false, {
message: 'Unknown user or invalid password'
});
}
var test = User.hashPassword(password);
// Call the Class Method - notice capital User vs lower case user
if (!user.authenticate(password)) {
return done(null, false, {
message: 'Unknown user or invalid password'
});
}
console.log('** Got User ' + user.first_name + " " + user._name);
return done(null, user);
}).catch(function(err) {
console.log('** Error Getting User: ' + err);
return done(err);
});
The text was updated successfully, but these errors were encountered:
You are passing the instance and class methods in a third object - they should inside the same options object as tableName, timestamps etc.
{updatedAt: 'updated',createdAt: 'created',tableName: 'user',// this will define the table's nametimestamps: false// this will deactivate the timestamp columns},{<---BEGONE!classMethods: {
I am trying to define an instance method and class method and am receiving a TypeError indicating that the methods are not defined. I am not sure what I have defined incorrectly.
Any insight is appreciated. Great library by the way!!
Below is the model definition and invocation. The error I get is
** Error Getting User: TypeError: undefined is not a function
When i try to call if (!user.authenticate(password)) ....
Here is the definition:
/* jshint indent: 2 */
var crypto = require('crypto');
module.exports = function(sequelize, DataTypes) {
};
Here is where I am calling from:
I added a var test = ... to see if the class methods were defined as well ...
User.find({
where: { username: username}
})
.then(function(user) {
The text was updated successfully, but these errors were encountered: