Skip to content

Commit

Permalink
Regression: Match name or fname when fetching room to send notifi…
Browse files Browse the repository at this point in the history
…cation for blocked log in attemps (#22067)
  • Loading branch information
KevLehman authored May 18, 2021
1 parent 2afbca0 commit 2dac1dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/authentication/server/lib/restrictLoginAttempts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const notifyFailedLogin = async (ipOrUsername: string, blockedUntil: Date
return;
}
// verify channel exists
const room = await Rooms.findOneByName(channelToNotify);
// to avoid issues when "fname" is presented in the UI, check if the name matches it as well
const room = await Rooms.findOneByNameOrFname(channelToNotify);
if (!room) {
/* @ts-expect-error */
logger.error('Cannot notify failed logins: channel provided doesn\'t exists');
Expand Down
4 changes: 4 additions & 0 deletions app/models/server/raw/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,8 @@ export class RoomsRaw extends BaseRaw {

return this.update(query, update, { multi: true });
}

findOneByNameOrFname(name, options = {}) {
return this.col.findOne({ $or: [{ name }, { fname: name }] }, options);
}
}

0 comments on commit 2dac1dd

Please sign in to comment.