diff --git a/src/Identity.Accounts/Models/Credentials.cs b/src/Identity.Accounts/Models/Credentials.cs index 8a0281e..94710d7 100644 --- a/src/Identity.Accounts/Models/Credentials.cs +++ b/src/Identity.Accounts/Models/Credentials.cs @@ -1,5 +1,5 @@ -// Copyright 2020 Carnegie Mellon University. -// Released under a MIT (SEI) license. See LICENSE.md in the project root. +// Copyright 2020 Carnegie Mellon University. +// Released under a MIT (SEI) license. See LICENSE.md in the project root. using System.Linq; using Identity.Accounts.Extensions; @@ -58,7 +58,7 @@ public class UsernameRegistration public UsernameRegistration(string value) { int x = value.IndexOf('<'); - int y = (x > 0) ? value.IndexOf('>', x) : 0; + int y = (x >= 0) ? value.IndexOf('>', x) : 0; Username = value.Substring(x+1, y>0 ? y-x-1 : value.Length - x - 1).Trim(); IsAffiliate = Username.ToLower().Contains(".ctr@"); DisplayName = (x > 0) diff --git a/src/Identity.Accounts/Services/AccountService.cs b/src/Identity.Accounts/Services/AccountService.cs index a40596c..0607ff2 100644 --- a/src/Identity.Accounts/Services/AccountService.cs +++ b/src/Identity.Accounts/Services/AccountService.cs @@ -199,7 +199,7 @@ public async Task RegisterExternalUser(ClaimsPrincipal principal, strin UpdateProperty(account, "origin", subClaim.Issuer); - if (_options.Registration.StoreEmail && email.IsEmailAddress()) + if (_options.Registration.StoreEmail && registration.Username.IsEmailAddress()) { UpdateProperty(account, ClaimTypes.Email, registration.Username); }