From 04b57153cb9cc8ab81f960b36ba365950870550d Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Wed, 5 Mar 2014 13:01:53 -0300 Subject: [PATCH] and that's how we do things in js --- models/users.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/users.js b/models/users.js index dd2f61a..87201fe 100644 --- a/models/users.js +++ b/models/users.js @@ -6,9 +6,12 @@ module.exports = function(sequelize, DataTypes) { issuedDate: DataTypes.DATE // since tokens are one way only, we need to make sure the token is valid for today }, { classMethods: { - userToken: function (reqToken) { - User.find({ token: reqToken }, success: function (user) { - // validade issuedDate + userToken: function (reqToken, next) { + User.find({ token: reqToken }).success(user) { + // check if the token is valid for today + if (next) { + next (user); + } } } }