Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Match name or fname when fetching room to send notification for blocked log in attemps #22067

Merged
merged 2 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}