Esempio n. 1
0
        public static bool TryExtractFromRequestCookie(this HttpCookieCollection cookies, out TokenEntity result)
        {
            if (!HttpContext.Current.Request.Cookies.AllKeys.Contains(AuthoriseBaseAttribute.ACCESSTOKEN) ||
                !HttpContext.Current.Request.Cookies.AllKeys.Contains(AuthoriseBaseAttribute.REFRESHTOKEN) ||
                !HttpContext.Current.Request.Cookies.AllKeys.Contains(AuthoriseBaseAttribute.CURRENT_USERID))
            {
                result = TokenEntity.Default();
                return(false);
            }

            //// take value from request form
            var accessToken   = HttpContext.Current.Request.Cookies[AuthoriseBaseAttribute.ACCESSTOKEN].Value;
            var refreshToken  = HttpContext.Current.Request.Cookies[AuthoriseBaseAttribute.REFRESHTOKEN].Value;
            var currentUserId = HttpContext.Current.Request.Cookies[AuthoriseBaseAttribute.CURRENT_USERID].Value;

            if (string.IsNullOrWhiteSpace(currentUserId))
            {
                currentUserId = TokenEntity.DEFAULT_USER_ID.ToString();
            }

            result = new TokenEntity(accessToken, refreshToken, DateTime.MinValue, long.Parse(currentUserId));
            return(true);
        }
 public RefreshTokenResult(bool isSuccess, string error, TokenEntity newToken)
 {
     IsSuccess = isSuccess;
     Error     = error;
     NewToken  = newToken;
 }