public async Task <IEnumerable <RefreshTokenResult> > ExecuteAsync(RefreshTokensQuery query)
        {
            var result = await _finder.All();

            return(await Task.Factory.StartNew(() =>
            {
                return result.Select(x => GetResult(x).Result).AsEnumerable();
            }));
        }
Ejemplo n.º 2
0
        private async Task <Result> GetResult(DeleteRefreshTokenByTokenCommand command)
        {
            var token =
                _finder.All().Result.FirstOrDefault(t => t.TicketId == command.TicketId);

            if (token == null)
            {
                return(Result.Fail("Could not find token"));
            }
            await _repo.Delete(token);

            return(Result.Ok());
        }
Ejemplo n.º 3
0
        private async Task <Result> VerifyNotExisting(string ticketId)
        {
            var existings = await _finder.All();

            return(await Task.Factory.StartNew(() =>
            {
                if (existings.FirstOrDefault(criteria => criteria.TicketId == ticketId) != null)
                {
                    return Result.Fail("Refresh token exists with");
                }
                return Result.Ok();
            }));
        }
Ejemplo n.º 4
0
        private Result Validate(RefreshTokenValidatorQuery query)
        {
            RefreshToken token =
                _finder.All().Result
                .FirstOrDefault(criteria => criteria.TicketId == query.TicketId);

            if (token == null)
            {
                return(Result.Fail("Unknown refresh token"));
            }

            if (token.UserId.Id != query.UserId || token.ClientId.Id != query.ClientId)
            {
                return(Result.Fail("Invalid refresh token"));
            }

            return(Result.Ok());
        }