示例#1
0
        public IDataResult <AccessToken> RefreshAccessToken(string refreshToken)
        {
            var userControl = _userService.GetById(UserId);

            if (userControl.Data == null)
            {
                return(new ErrorDataResult <AccessToken>(Messages.InvalidToken));
            }

            var _refreshToken = _refreshTokenDal.Get(w => w.UserId == UserId && w.Token == refreshToken);

            if (_refreshToken == null)
            {
                return(new ErrorDataResult <AccessToken>(Messages.InvalidToken));
            }
            else if (!_refreshToken.IsActive)
            {
                _refreshTokenDal.Delete(_refreshToken);
                return(new ErrorDataResult <AccessToken>(Messages.TokenTimeOut));
            }

            _refreshTokenDal.Delete(_refreshToken);

            return(CreateAccessToken(userControl.Data));
        }
        public IDataResult <RefreshToken> GetByToken(string refreshToken)
        {
            var result = _refreshTokenDal.Get(x => x.Token == refreshToken);

            return(new SuccessDataResult <RefreshToken>(result));
        }