You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// PostgreSQL text comparison is case-sensitive (unlike SQL Server's default collation),
67
-
// so match on normalizedusername the same way ASP.NET Identity sign-in does. Otherwise a
68
-
// user who authenticated with different casing than the stored username is not found here.
66
+
// aspnetusers columns are citext (case-insensitive), so match on the same key ASP.NET
67
+
// Identity authenticated against -- normalizedusername -- so a row whose username and
68
+
// normalizedusername have drifted apart is still found here.
69
69
varresult=awaitdb.QueryAsync<IdentityUser>($"SELECT * FROM aspnetusers WHERE normalizedusername = @normalizedUserName",new{normalizedUserName=userName?.ToUpperInvariant()});
70
70
71
71
returnresult.FirstOrDefault();
@@ -90,9 +90,9 @@ public IdentityUser GetUserByEmail(string email)
db.Execute($"UPDATE [AspNetUsers] SET [UserName] = @newUsername, [NormalizedUserName] = @newUsernameUpper WHERE UserName = @oldUsername",new{newUsername=newUsername,newUsernameUpper=newUsername.ToUpper(),oldUsername=oldUsername});
123
+
db.Execute($"UPDATE [AspNetUsers] SET [UserName] = @newUsername, [NormalizedUserName] = @newUsernameUpper WHERE UserName = @oldUsername",new{newUsername=newUsername,newUsernameUpper=newUsername.ToUpperInvariant(),oldUsername=oldUsername});
124
124
}
125
125
}
126
126
}
@@ -133,14 +133,14 @@ public void UpdateEmail(string userId, string newEmail)
133
133
{
134
134
// Keep normalizedemail in sync (ASP.NET Identity's FindByEmailAsync looks up by it); the
135
135
// SQL Server branch already does this. Without it, email lookups go stale after a change.
136
-
db.Execute($"UPDATE public.aspnetusers SET email = @newEmail, normalizedemail = @newEmailUpper WHERE id = @userId",new{userId=userId,newEmail=newEmail,newEmailUpper=newEmail?.ToUpper()});
136
+
db.Execute($"UPDATE public.aspnetusers SET email = @newEmail, normalizedemail = @newEmailUpper WHERE id = @userId",new{userId=userId,newEmail=newEmail,newEmailUpper=newEmail?.ToUpperInvariant()});
db.Execute($"UPDATE [AspNetUsers] SET [Email] = @newEmail, [NormalizedEmail] = @newEmailUpper WHERE Id = @userId",new{userId=userId,newEmail=newEmail,newEmailUpper=newEmail.ToUpper()});
143
+
db.Execute($"UPDATE [AspNetUsers] SET [Email] = @newEmail, [NormalizedEmail] = @newEmailUpper WHERE Id = @userId",new{userId=userId,newEmail=newEmail,newEmailUpper=newEmail.ToUpperInvariant()});
144
144
}
145
145
}
146
146
}
@@ -469,22 +469,41 @@ public async Task<bool> ClearOutUserLoginAsync(string userId)
469
469
{
470
470
vardeleteId=Guid.NewGuid().ToString();
471
471
varmaskedEmail=deleteId+"@resgrid.del";
472
+
// Full de-provisioning: mask the normalized columns too (so ASP.NET Identity's normalized
473
+
// lookups can't find the row), null the password hash, rotate the security stamp, and lock
474
+
// the account so a deleted user can no longer authenticate.
0 commit comments