public override async Task <DomainValidationResult <object> > GenerateAuthenticationAsync(UserId userId, LeagueOfLegendsRequest request) { try { var result = new DomainValidationResult <object>(); var summoner = await _leagueOfLegendsService.Summoner.GetSummonerByNameAsync(Region.Na, request.SummonerName); if (await _gameCredentialRepository.CredentialExistsAsync(PlayerId.Parse(summoner.AccountId), Game)) { result.AddFailedPreconditionError("Summoner's name is already linked by another eDoxa account"); } if (result.IsValid) { if (await _gameAuthenticationRepository.AuthenticationExistsAsync(userId, Game)) { await _gameAuthenticationRepository.RemoveAuthenticationAsync(userId, Game); } var gameAuthentication = await this.GenerateAuthFactor(summoner); await _gameAuthenticationRepository.AddAuthenticationAsync(userId, Game, gameAuthentication); return(gameAuthentication.Factor); } return(result); } catch (RiotSharpException) { return(DomainValidationResult <object> .Failure("Summoner name is invalid")); } }
public async Task <bool> AuthenticationExistsAsync(UserId userId, Game game) { return(await _gameAuthenticationRepository.AuthenticationExistsAsync(userId, game)); }