Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## UNRELEASED

### Adds

* Uses core login `normalizeLoginName` method to lowercase username and email in case project login option `caseInsensitive` is set to true.

## 1.5.2 (2025-08-27)

* Fixed regression introduced in 1.5.0-beta.1 that made it more difficult to see the logs regarding certain types of login failures and account creation issues. This issue was particularly likely to occur with strategies that do not supply `req`.
Expand Down
18 changes: 11 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ module.exports = {
self.apos.util.error('@apostrophecms/passport-bridge: profile has no username. You probably want to set the "match" option for this strategy to "id" or "email".');
return callback(null, false);
}
criteria.username = profile.username;
criteria.username = self.apos.login.normalizeLoginName(
profile.username
);
break;
case 'email':
case 'emails':
Expand All @@ -328,7 +330,9 @@ module.exports = {
return callback(null, false);
}
criteria.$or = emails.map(email => {
return { email };
return {
email: self.apos.login.normalizeLoginName(email)
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normalize in criteria to retrieve the user based on apps user info.

});
break;
default:
Expand Down Expand Up @@ -485,15 +489,15 @@ module.exports = {
async createUser(spec, profile) {
const user = self.apos.user.newInstance();
user.role = await self.userRole();
user.username = profile.username;
user.username = self.apos.login.normalizeLoginName(profile.username);
user[spec.name + 'Id'] = profile.id;
const emails = self.getRelevantEmailsFromProfile(spec, profile);
if (emails.length) {
user.email = emails[0];
const [ email ] = self.getRelevantEmailsFromProfile(spec, profile);
if (email) {
user.email = self.apos.login.normalizeLoginName(email);
}
// Try hard to come up with a title, as without a slug we'll get an error
// at insert time
user.title = profile.displayName || profile.username || user.email || '';
user.title = profile.displayName || profile.username || email || '';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses non normlized email for title.

user.username = user.username || user.email || self.apos.util.slugify(user.title);
if (profile.name) {
user.firstName = profile.name.givenName;
Expand Down