diff --git a/src/Spd.Manager.Licence/BizProfileManager.cs b/src/Spd.Manager.Licence/BizProfileManager.cs index bf043fb06..79f1d1cb0 100644 --- a/src/Spd.Manager.Licence/BizProfileManager.cs +++ b/src/Spd.Manager.Licence/BizProfileManager.cs @@ -97,8 +97,10 @@ public async Task 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(portalUser); response.BceidBizTradeName = bizInfoFormBceid?.TradeName; + return response; } else @@ -239,6 +241,16 @@ private async Task AddPortalUserToBiz(BceidIdentityInfo info, Gu }, ct); } + private async Task 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 branches, List branchesToProcess, Guid bizId, CancellationToken ct) { // Remove branches defined in the entity that are not part of the request diff --git a/src/Spd.Utilities.LogonUser/IPrincipalExtensions.cs b/src/Spd.Utilities.LogonUser/IPrincipalExtensions.cs index d249afe8a..692ef47c9 100644 --- a/src/Spd.Utilities.LogonUser/IPrincipalExtensions.cs +++ b/src/Spd.Utilities.LogonUser/IPrincipalExtensions.cs @@ -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("display_name"), Email = claim.GetClaimValue(BCeID_Email), - FirstName = claim.GetClaimValue(BCeID_GIVEN_NAME), - LastName = claim.GetClaimValue(BCeID_SUR_NAME), + FirstName = GetBceidUserFirstName(claim.GetClaimValue("name")), + LastName = GetBceidUserLastName(claim.GetClaimValue("name")), PreferredUserName = claim.GetClaimValue("preferred_username"), BCeIDUserName = claim.GetClaimValue("bceid_username"), UserGuid = claim.GetClaimValue("bceid_user_guid"), @@ -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(); + } } } \ No newline at end of file