Skip to content

Commit dd4fbb8

Browse files
authored
Merge pull request #110 from i-pip/fix/case-sensitive-emails
fix: case-insensitive user emails - issue #89
2 parents 5b0c28e + 8734b6d commit dd4fbb8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

models/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func NewUser(instanceID uuid.UUID, email, password, aud string, userData map[str
6565
InstanceID: instanceID,
6666
ID: id,
6767
Aud: aud,
68-
Email: email,
68+
Email: strings.ToLower(email),
6969
UserMetaData: userData,
7070
EncryptedPassword: pw,
7171
}
@@ -265,7 +265,7 @@ func FindUserByConfirmationToken(tx *storage.Connection, token string) (*User, e
265265

266266
// FindUserByEmailAndAudience finds a user with the matching email and audience.
267267
func FindUserByEmailAndAudience(tx *storage.Connection, instanceID uuid.UUID, email, aud string) (*User, error) {
268-
return findUser(tx, "instance_id = ? and email = ? and aud = ?", instanceID, email, aud)
268+
return findUser(tx, "instance_id = ? and LOWER(email) = ? and aud = ?", instanceID, strings.ToLower(email), aud)
269269
}
270270

271271
// FindUserByID finds a user matching the provided ID.

0 commit comments

Comments
 (0)