private Client GetUserClient(string clientKey)
        {
            var result = _clientFinder.All().Result;
            var client = result.FirstOrDefault(criteria => criteria.Key.Equals(clientKey));

            if (client == null)
            {
                var message = $"Client '{clientKey}' is not registered in the system.";
                throw new FailureResult(message);
            }
            return(client);
        }
        private async Task <Result> VerifyNotExisting(string key)
        {
            var existings = await _finder.All();

            return(await Task.Factory.StartNew(() =>
            {
                if (existings.FirstOrDefault(criteria => criteria.Key == key) != null)
                {
                    return Result.Fail("Client already exists");
                }
                return Result.Ok();
            }));
        }
Beispiel #3
0
        private ValidateClientResult GetResult(ValidateClientQuery query)
        {
            var result = _clientFinder.All().Result;
            var client = result.FirstOrDefault(criteria => criteria.Key.Equals(query.ClientId));

            if (client == null)
            {
                return(ValidateClientResult.Failed($"Client '{query.ClientId}' is not registered in the system."));
            }

            if (!client.Active)
            {
                return(ValidateClientResult.Failed("Client is inactive."));
            }

            return(new ValidateClientResult(true, client.Id.Id, client.Name, client.AllowedOrigin, client.RedirectUri));
        }