Skip to content

Commit

Permalink
Merge pull request #490 from bcgov/yj
Browse files Browse the repository at this point in the history
chore: bceid egress
  • Loading branch information
ychung-mot authored Jul 24, 2024
2 parents 6979c06 + d74e18f commit 74a0211
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/StrDss.Api/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,13 @@ public async Task<ActionResult> UpdateUser(long userId, UserUpdateDto dto)

return Ok();
}

[ApiAuthorize]
[HttpGet("currentuser/bceiduserinfo", Name = "GetBceidUserInfo")]
public async Task<ActionResult> GetBceidUserInfo()
{
var userinfo = await _userService.GetBceidUserInfo();
return Ok(userinfo);
}
}
}
20 changes: 20 additions & 0 deletions server/StrDss.Service/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public interface IUserService
Task UpdateBceidUserInfo(long userId, string firstName, string LastName);
Task<UserDto?> GetUserByIdAsync(long userId);
Task<Dictionary<string, List<string>>> UpdateUserAsync(UserUpdateDto dto);
Task<BceidAccount?> GetBceidUserInfo();
}
public class UserService : ServiceBase, IUserService
{
Expand Down Expand Up @@ -496,5 +497,24 @@ public async Task<Dictionary<string, List<string>>> ValidateUserUpdateDto(UserUp

return errors;
}

public async Task<BceidAccount?> GetBceidUserInfo()
{
if (_currentUser.IdentityProviderNm == StrDssIdProviders.BceidBusiness)
{
try
{
var (error, account) = await _bceid.GetBceidAccountCachedAsync(_currentUser.UserGuid, "", StrDssIdProviders.BceidBusiness, _currentUser.UserGuid, _currentUser.IdentityProviderNm);
return account;
}
catch (Exception ex)
{
_logger.LogError($"BCeID Web call failed - {ex.Message}", ex);
_logger.LogInformation("BCeID Web call failed - Skipping UpdateBceidUserInfo ");
}
}

return null;
}
}
}

0 comments on commit 74a0211

Please sign in to comment.