From 462d8bedbfefb5a4e63db3c745069a8ab7613773 Mon Sep 17 00:00:00 2001 From: Jeff Mattson Date: Thu, 9 May 2024 16:31:22 -0400 Subject: [PATCH] wip --- src/Identity.Accounts/Models/Credentials.cs | 6 +++--- src/Identity.Accounts/Services/AccountService.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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); }