Skip to content

Commit 0cc2b5b

Browse files
committed
Fix detection of logoutSessionsOnSensitiveChanges
Modify the code detecting whether logoutSessionsOnSensitiveChanges is enabled to correctly handle the case when the model is not attached to any application, as is the case with loopback-component-passport tests.
1 parent 05db433 commit 0cc2b5b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

common/models/user.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,9 @@ module.exports = function(User) {
867867
});
868868

869869
User.observe('before save', function prepareForTokenInvalidation(ctx, next) {
870-
if (!ctx.Model.app.get('logoutSessionsOnSensitiveChanges')) return next();
870+
var invalidationEnabled = ctx.Model.app &&
871+
ctx.Model.app.get('logoutSessionsOnSensitiveChanges');
872+
if (!invalidationEnabled) return next();
871873

872874
if (ctx.isNewInstance) return next();
873875
if (!ctx.where && !ctx.instance) return next();
@@ -909,7 +911,9 @@ module.exports = function(User) {
909911
});
910912

911913
User.observe('after save', function invalidateOtherTokens(ctx, next) {
912-
if (!ctx.Model.app.get('logoutSessionsOnSensitiveChanges')) return next();
914+
var invalidationEnabled = ctx.Model.app &&
915+
ctx.Model.app.get('logoutSessionsOnSensitiveChanges');
916+
if (!invalidationEnabled) return next();
913917

914918
if (!ctx.instance && !ctx.data) return next();
915919
if (!ctx.hookState.originalUserData) return next();

0 commit comments

Comments
 (0)