Skip to content

Commit

Permalink
Merge pull request #319 from bcgov/yj
Browse files Browse the repository at this point in the history
chore: disable update bceid user info
  • Loading branch information
ychung-mot authored May 28, 2024
2 parents 76e312b + 3b3b740 commit d3f2ac4
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions server/StrDss.Api/Authentication/KcJwtBearerEvents.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using StrDss.Common;
using StrDss.Model;
using StrDss.Model.UserDtos;
using StrDss.Service;
using StrDss.Service.Bceid;

Expand Down Expand Up @@ -78,33 +79,38 @@ public override async Task TokenValidated(TokenValidatedContext context)
}
}

if (user.IdentityProviderNm == StrDssIdProviders.BceidBusiness && (int)(DateTime.UtcNow - user!.UpdDtm).TotalDays > 1)
//await UpdateBceidUserInfo(user);
}
}

private async Task UpdateBceidUserInfo(UserDto? user)
{
if (user!.IdentityProviderNm == StrDssIdProviders.BceidBusiness && (int)(DateTime.UtcNow - user!.UpdDtm).TotalDays > 1)
{
try
{
try
var (error, account) = await _bceid.GetBceidAccountCachedAsync(_currentUser.UserGuid, "", StrDssIdProviders.BceidBusiness, _currentUser.UserGuid, _currentUser.IdentityProviderNm);

if (account == null)
{
var (error, account) = await _bceid.GetBceidAccountCachedAsync(_currentUser.UserGuid, "", StrDssIdProviders.BceidBusiness, _currentUser.UserGuid, _currentUser.IdentityProviderNm);
_logger.LogError($"BCeID call error: {error}");
}

if (account == null)
{
_logger.LogError($"BCeID call error: {error}");
}
if (account != null)
{
_currentUser.FirstName = account.FirstName;
_currentUser.LastName = account.LastName;

if (account != null)
if (account.FirstName != user.GivenNm || account.LastName != user.FamilyNm)
{
_currentUser.FirstName = account.FirstName;
_currentUser.LastName = account.LastName;

if (account.FirstName != user.GivenNm || account.LastName != user.FamilyNm)
{
await _userService.UpdateBceidUserInfo(user.UserIdentityId, account.FirstName, account.LastName);
}
await _userService.UpdateBceidUserInfo(user.UserIdentityId, account.FirstName, account.LastName);
}
}
catch (Exception ex)
{
_logger.LogError($"BCeID Web call failed - {ex.Message}", ex);
_logger.LogInformation("BCeID Web call failed - Skipping UpdateBceidUserInfo ");
}
}
catch (Exception ex)
{
_logger.LogError($"BCeID Web call failed - {ex.Message}", ex);
_logger.LogInformation("BCeID Web call failed - Skipping UpdateBceidUserInfo ");
}
}
}
Expand Down

0 comments on commit d3f2ac4

Please sign in to comment.