/// <summary> /// /// </summary> /// <param name="command"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task HandleAsync(LoginCommand command, CancellationToken cancellationToken = default(CancellationToken)) { _logger.LogInformation("START AUTHENTICATION ACCOUNT ...."); var tokenResponse = await _accountService.LoginAsync(command, cancellationToken); var handler = new JwtSecurityTokenHandler(); var jwtSecurityToken = handler.ReadJwtToken(tokenResponse.AccessToken); var accountId = Guid.Parse(jwtSecurityToken.Subject); _logger.LogInformation("LOGIN SUCCESS"); _applicationContext.UserInfo.AccessToken = tokenResponse.AccessToken; _applicationContext.UserInfo.RefreshToken = tokenResponse.RefreshToken; _applicationContext.UserInfo.UserId = accountId; // get banking account var DebitAccountModel = await _bankingService.GetBankingAccountByUserIdAsync(accountId, cancellationToken); if (DebitAccountModel == null) { DebitAccountModel = await _bankingService.CreateDebitAccountAsync(accountId, cancellationToken); } _applicationContext.UserInfo.DebitAccountId = DebitAccountModel.Id; }