From 454e5ec749e8657eb2372b68d01d0d4a8266ec46 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 13 Nov 2019 12:01:50 +0100 Subject: [PATCH] . --- core/passport.js | 9 +++------ modules/auth/user.model.js | 2 +- modules/auth/user.service.js | 15 +++++++-------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/core/passport.js b/core/passport.js index a80c5c5..8a247e8 100644 --- a/core/passport.js +++ b/core/passport.js @@ -116,12 +116,9 @@ passport.use('jwt', new CustomStrategy(async (req, done) => { let user = await authService.extraMethods.findUser({ id: result.id }); if (user) { user = user.toJSON(); - if (appVersion) { - if (user.app_version != appVersion){ - const result = userService._updateLastLoginAndVersionUser(user.id, appVersion); - user.app_version = appVersion; - } - } + const result = userService._updateLastLoginAndVersionUser(user.id, appVersion); + user.app_version = appVersion; + delete user.password; console.log('Logged in Successfully'); return done(null, user, { message: 'Logged in Successfully' }); diff --git a/modules/auth/user.model.js b/modules/auth/user.model.js index 1da9242..0af072e 100644 --- a/modules/auth/user.model.js +++ b/modules/auth/user.model.js @@ -77,7 +77,7 @@ module.exports = function (sequelize, DataTypes) { User.Comments = User.hasMany(models.Comment, { foreignKey: 'userId' }); User.EventsReservations = User.hasMany(models.EventReservation, { foreignKey: 'userId' }); User.EventsInscriptions = User.hasMany(models.EventInscription, { foreignKey: 'userId' }); - User.Questions = User.hasMany(models.EventQuestion, { foreignKey: 'userId', as: "questions", required: false, }); + User.Questions = User.hasMany(models.EventQuestion, { foreignKey: 'userId', as: "questions", required: false }); // User.InscriptionsValidate = User.hasMany(models.EventIncription, { foreignkey: 'validateUserId'}) //User.Reactions = User.hasMany(models.UserReaction, { foreignKey: 'UserId' }); diff --git a/modules/auth/user.service.js b/modules/auth/user.service.js index ea39c22..59823a5 100644 --- a/modules/auth/user.service.js +++ b/modules/auth/user.service.js @@ -26,14 +26,13 @@ const extraMethods = { }) }, - _updateLastLoginAndVersionUser: async (Id, appVersion) => { - return models.User.update ( - { app_version : appVersion, - lastlogin: moment().utc() }, - { - where: { id: Id} - }, - ); + _updateLastLoginAndVersionUser: async (id, appVersion) => { + return models.User.update ({ + app_version : appVersion, + lastlogin: moment().utc() + }, { + where: { id: id } + }); }, _getOrCreateUser: async (dataUser) => {