Skip to content

Commit dac1295

Browse files
authored
Merge pull request #3016 from strongloop/fix/repeated-user-hooks2
Fix registration of operation hooks in User model (part 2)
2 parents 57a053b + f476613 commit dac1295

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

common/models/user.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,6 @@ module.exports = function(User) {
682682
}
683683
};
684684

685-
// Access token to normalize email credentials
686-
UserModel.observe('access', function normalizeEmailCase(ctx, next) {
687-
if (!ctx.Model.settings.caseSensitiveEmail && ctx.query.where &&
688-
ctx.query.where.email && typeof(ctx.query.where.email) === 'string') {
689-
ctx.query.where.email = ctx.query.where.email.toLowerCase();
690-
}
691-
next();
692-
});
693-
694685
// Make sure emailVerified is not set by creation
695686
UserModel.beforeRemote('create', function(ctx, user, next) {
696687
var body = ctx.req.body;
@@ -818,6 +809,15 @@ module.exports = function(User) {
818809
// Important: Operation hooks are inherited by subclassed models,
819810
// therefore they must be registered outside of setup() function
820811

812+
// Access token to normalize email credentials
813+
User.observe('access', function normalizeEmailCase(ctx, next) {
814+
if (!ctx.Model.settings.caseSensitiveEmail && ctx.query.where &&
815+
ctx.query.where.email && typeof(ctx.query.where.email) === 'string') {
816+
ctx.query.where.email = ctx.query.where.email.toLowerCase();
817+
}
818+
next();
819+
});
820+
821821
// Delete old sessions once email is updated
822822
User.observe('before save', function beforeEmailUpdate(ctx, next) {
823823
if (ctx.isNewInstance) return next();

0 commit comments

Comments
 (0)