public IActionResult GetUserInfo(string accessToken) { var tokenDto = TokensRepository.Get(accessToken); if (tokenDto == null) { throw new Exception("Invalid token"); } IBankApi bankApi; switch (tokenDto.BankId) { case BankEnum.Seb: bankApi = new SebApi(); break; case BankEnum.MobileSign: bankApi = new IsignMobileApi(); break; default: throw new Exception("Bank not supported"); } var userInfo = bankApi.GetUserInfo(tokenDto); return(Ok(userInfo)); }
public IActionResult GetRedirectFromBank(BankEnum bankId, string userId) { IBankApi bankApi; switch (bankId) { case BankEnum.Seb: //should differ from swed bankApi = new SebApi(); break; case BankEnum.MobileSign: bankApi = new IsignMobileApi(); break; default: throw new Exception("Bank not supported"); } var tokenDto = bankApi.GetAuthorized(userId); TokensRepository.Add(tokenDto); return(Redirect($"http://localhost:3000/link?token={tokenDto.Token}")); }