private async Task ValidateTokenData(IAuthTokenHolder authTokenHolder) { if (authTokenHolder == null) { throw new ValidationException("Authentication token not found"); } await GameActions.ValidateTokenAsync(authTokenHolder); }
private Guid GetPlayerIdFromToken(IAuthTokenHolder request) { return(TokenProvider.Decrypt(request.AuthToken)); }
async Task <ValidateTokenResponse> ICommonGameActionsProvider.ValidateTokenAsync(IAuthTokenHolder request) { if (_useRealUgs) { var client = _flycowApiClientProvider.GetApiClient(); var token = await _flycowApiClientProvider.GetApiToken(client); var validationResponse = await client.ValidateTokenAsync(new ValidateTokenRequest { authtoken = request.AuthToken, ipaddress = request.PlayerIpAddress }, token); if (validationResponse.err != (int)UgsApiError.None) { throw new InvalidTokenException("Token validation failed with description: " + validationResponse.errdesc); } return(new ValidateTokenResponse { Balance = validationResponse.bal, PlayerId = validationResponse.userid, PlayerDisplayName = validationResponse.username, BrandCode = validationResponse.brand, Language = validationResponse.lang, CurrencyCode = validationResponse.cur, BetLimitCode = validationResponse.betlimitid }); } var playerId = GetPlayerIdFromToken(request); var playerData = await _gameQueries.GetPlayerDataAsync(playerId); // Get player if (playerData == null) { throw new PlayerNotFoundException("Cannot find player with id=" + playerId); } var balance = await _gameQueries.GetPlayableBalanceAsync(playerId); // Get balance var brandCode = await _gameQueries.GetBrandCodeAsync(playerData.BrandId); // Get brand code var playerBetLimitCode = await _gameQueries.GetPlayerBetLimitCodeOrNullAsync(playerData.VipLevelId, Context.GameProviderCode, playerData.CurrencyCode); var balanceCurrencyCode = await _gameQueries.GetMappedGameProviderCurrencyCodeAsync(Context.GameProviderCode, balance.CurrencyCode); return(new ValidateTokenResponse { Balance = balance.Balance, PlayerId = playerData.Id, PlayerDisplayName = playerData.Name, BrandCode = brandCode ?? string.Empty, Language = playerData.CultureCode ?? string.Empty, CurrencyCode = balanceCurrencyCode, BetLimitCode = playerBetLimitCode ?? "" }); }