Skip to content

Commit

Permalink
fix(identity): change identity service to scoped (#370)
Browse files Browse the repository at this point in the history
Refs: CPLP-3102
  • Loading branch information
Phil91 authored Dec 4, 2023
1 parent 64b36a0 commit e4a9057
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static IServiceCollection AddConfigurationIdentityService(this IServiceCo
.ValidateOnStart();

return services
.AddTransient<IIdentityIdDetermination, ConfigurationIdentityIdDetermination>()
.AddTransient<IIdentityService, IdentityService>();
.AddScoped<IIdentityIdDetermination, ConfigurationIdentityIdDetermination>()
.AddScoped<IIdentityService, IdentityService>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public static IServiceCollection AddClaimsIdentityIdDetermination(this IServiceC
{
return services
.AddScoped<IIdentityIdDetermination, ClaimsIdentityIdDetermination>()
.AddTransient<IIdentityService, IdentityService>();
.AddScoped<IIdentityService, IdentityService>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public IdentityService(IPortalRepositories portalRepositories, IIdentityIdDeterm

/// <inheritdoc />
public async ValueTask<IdentityData> GetIdentityData() =>
_identityData ??= await _identityRepository.GetActiveIdentityDataByIdentityId(IdentityId).ConfigureAwait(false) ?? throw new ConflictException($"Identity {_identityIdDetermination.IdentityId} could not be found");
_identityData ?? (_identityData =
await _identityRepository.GetActiveIdentityDataByIdentityId(IdentityId).ConfigureAwait(false) ??
throw new ConflictException($"Identity {_identityIdDetermination.IdentityId} could not be found"));

public IdentityData IdentityData => _identityData ?? throw new UnexpectedConditionException("identityData should never be null here (endpoint must be annotated with an identity policy / as an alternative GetIdentityData should be used)");

Expand Down

0 comments on commit e4a9057

Please sign in to comment.