Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bceid user name issue #1668

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Spd.Manager.Licence/BizProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ public async Task<BizUserLoginResponse> Handle(BizLoginCommand cmd, Cancellation
//return the loginResponse
//update the biz
await UpdateBiz(cmd, bizInfoFormBceid, ct);
await UpdatePortalUser(cmd.BceidIdentityInfo, portalUser.Id, ct);
BizUserLoginResponse response = _mapper.Map<BizUserLoginResponse>(portalUser);
response.BceidBizTradeName = bizInfoFormBceid?.TradeName;

return response;
}
else
Expand Down Expand Up @@ -239,6 +241,16 @@ private async Task<PortalUserResp> AddPortalUserToBiz(BceidIdentityInfo info, Gu
}, ct);
}

private async Task<PortalUserResp> UpdatePortalUser(BceidIdentityInfo info, Guid portalUserId, CancellationToken ct)
{
return await _portalUserRepository.ManageAsync(new UpdatePortalUserCmd()
{
Id = portalUserId,
FirstName = info.FirstName,
LastName = info.LastName,
}, ct);
}

private async Task ProcessBranchAddresses(List<BranchAddr> branches, List<BranchAddr> branchesToProcess, Guid bizId, CancellationToken ct)
{
// Remove branches defined in the entity that are not part of the request
Expand Down
19 changes: 17 additions & 2 deletions src/Spd.Utilities.LogonUser/IPrincipalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ public static BcscIdentityInfo GetBcscUserIdentityInfo(this IPrincipal principal
public static BceidIdentityInfo GetBceidUserIdentityInfo(this IPrincipal principal)
{
var claim = ValidatePrincipal(principal);

return new BceidIdentityInfo()
{
DisplayName = claim.GetClaimValue<string>("display_name"),
Email = claim.GetClaimValue<string>(BCeID_Email),
FirstName = claim.GetClaimValue<string>(BCeID_GIVEN_NAME),
LastName = claim.GetClaimValue<string>(BCeID_SUR_NAME),
FirstName = GetBceidUserFirstName(claim.GetClaimValue<string>("name")),
LastName = GetBceidUserLastName(claim.GetClaimValue<string>("name")),
PreferredUserName = claim.GetClaimValue<string>("preferred_username"),
BCeIDUserName = claim.GetClaimValue<string>("bceid_username"),
UserGuid = claim.GetClaimValue<Guid?>("bceid_user_guid"),
Expand Down Expand Up @@ -151,5 +152,19 @@ public static (string?, string?) GetMiddleNames(string? gns, string? fn)
}
return (null, null);
}

private static string? GetBceidUserFirstName(string? name)
{
if (name == null) return null;
string[] n = name.Split(' ');
return n[0].Trim();
}

private static string? GetBceidUserLastName(string? name)
{
if (name == null) return null;
string[] n = name.Split(' ');
return name.Substring(n[0].Length).Trim();
}
}
}