Skip to content

Commit

Permalink
Improve login error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Jul 31, 2017
1 parent 87b435c commit 5753c31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Package.onUse(function(api) {
api.addFiles('server/lib/configLogger.js', 'server');
api.addFiles('server/lib/PushNotification.js', 'server');
api.addFiles('server/lib/defaultBlockedDomainsList.js', 'server');
api.addFiles('server/lib/loginErrorMessageOverride.js', 'server');
api.addFiles('server/lib/notifyUsersOnMessage.js', 'server');
api.addFiles('server/lib/roomTypes.js', 'server');
api.addFiles('server/lib/sendEmailOnMessage.js', 'server');
Expand Down
11 changes: 11 additions & 0 deletions packages/rocketchat-lib/server/lib/loginErrorMessageOverride.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Do not disclose if user exists when password is invalid
const _runLoginHandlers = Accounts._runLoginHandlers;
Accounts._runLoginHandlers = function(methodInvocation, options) {
const result = _runLoginHandlers.call(Accounts, methodInvocation, options);

if (result.error && result.error.reason === 'Incorrect password') {
result.error = new Meteor.Error(403, 'User not found');
}

return result;
};

0 comments on commit 5753c31

Please sign in to comment.