Skip to content

Commit 27ad8f9

Browse files
authored
Rename OneLoginUser.Email to EmailAddress (#2684)
Keeps it consistent with other email address fields.
1 parent d89d453 commit 27ad8f9

File tree

16 files changed

+21389
-49
lines changed

16 files changed

+21389
-49
lines changed

TeachingRecordSystem/src/TeachingRecordSystem.AuthorizeAccess/Controllers/OAuth2Controller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public async Task<IActionResult> UserInfoAsync()
157157

158158
if (User.HasScope(Scopes.Email))
159159
{
160-
claims.Add(ClaimTypes.Email, oneLoginUser.Email!);
160+
claims.Add(ClaimTypes.Email, oneLoginUser.EmailAddress!);
161161
}
162162

163163
if (oneLoginUser.VerificationRoute == OneLoginUserVerificationRoute.OneLogin)

TeachingRecordSystem/src/TeachingRecordSystem.AuthorizeAccess/SignInJourneyHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public async Task OnUserAuthenticatedAsync(JourneyInstance<SignInJourneyState> j
8484
oneLoginUser = new()
8585
{
8686
Subject = sub,
87-
Email = email,
87+
EmailAddress = email,
8888
FirstOneLoginSignIn = clock.UtcNow,
8989
LastOneLoginSignIn = clock.UtcNow
9090
};
@@ -97,7 +97,7 @@ public async Task OnUserAuthenticatedAsync(JourneyInstance<SignInJourneyState> j
9797

9898
// Email may have changed since the last sign in or we may have never had it (e.g. if we got the user ID over our API).
9999
// TODO Should we emit an event if it has changed?
100-
oneLoginUser.Email = email;
100+
oneLoginUser.EmailAddress = email;
101101

102102
if (oneLoginUser.PersonId is not null)
103103
{
@@ -224,7 +224,7 @@ await journeyInstance.UpdateStateAsync(state =>
224224
if (getAnIdentityPerson is null)
225225
{
226226
var identityUser = await idDbContext.Users.SingleOrDefaultAsync(
227-
u => u.EmailAddress == oneLoginUser.Email
227+
u => u.EmailAddress == oneLoginUser.EmailAddress
228228
&& u.Trn != null
229229
&& u.IsDeleted == false
230230
&& (u.TrnVerificationLevel == TrnVerificationLevel.Medium
@@ -334,11 +334,11 @@ public async Task<bool> TryMatchToTeachingRecordAsync(JourneyInstance<SignInJour
334334

335335
private async Task<TryMatchToTrnRequestResult?> TryMatchToTrnRequestAsync(OneLoginUser oneLoginUser)
336336
{
337-
Debug.Assert(oneLoginUser.Email is not null);
337+
Debug.Assert(oneLoginUser.EmailAddress is not null);
338338

339339
var requestAndResolvedPerson = await dbContext.TrnRequestMetadata
340340
.Join(dbContext.Persons, r => r.ResolvedPersonId, p => p.PersonId, (m, p) => new { TrnRequestMetadata = m, ResolvedPerson = p })
341-
.Where(m => m.TrnRequestMetadata.OneLoginUserSubject == oneLoginUser.Subject || m.TrnRequestMetadata.EmailAddress == oneLoginUser.Email)
341+
.Where(m => m.TrnRequestMetadata.OneLoginUserSubject == oneLoginUser.Subject || m.TrnRequestMetadata.EmailAddress == oneLoginUser.EmailAddress)
342342
.ToArrayAsync();
343343

344344
if (requestAndResolvedPerson is not [{ TrnRequestMetadata: var trnRequestMetadata, ResolvedPerson: var resolvedPerson }])

TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Mappings/OneLoginUserMapping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void Configure(EntityTypeBuilder<OneLoginUser> builder)
1212
{
1313
builder.HasKey(o => o.Subject);
1414
builder.Property(o => o.Subject).HasMaxLength(255);
15-
builder.Property(o => o.Email).HasMaxLength(200);
15+
builder.Property(o => o.EmailAddress).HasMaxLength(200);
1616
builder.HasOne(o => o.Person).WithOne().HasForeignKey<OneLoginUser>(o => o.PersonId);
1717
builder.Property(o => o.VerifiedNames).HasColumnType("jsonb").HasConversion(
1818
v => JsonSerializer.Serialize(v, (JsonSerializerOptions?)null),

0 commit comments

Comments
 (0)