/// <summary> /// Re-validates the user session. Usually called at each authorization request. /// If the session is not expired, extends it lifetime and returns true. /// If the session is expired or does not exist, return false. /// </summary> /// <returns>true if the session is valid</returns> public bool ReValidateSession(out Dictionary<HttpStatusCode, string> errorResponse) { errorResponse = new Dictionary<HttpStatusCode, string>(); string authToken = this.GetCurrentBearerAuthrorizationToken(); ITokenDetailRepository tokenDetailRepository = new TokenDetailRepository(); ITokenDetailBL tokenDetailBl = new TokenDetailBL(tokenDetailRepository); CachedData cachedData = new CachedData(tokenDetailBl); if (!string.IsNullOrEmpty(authToken)) { var currentUserId = this.GetCurrentUserId(); var getUserTokens = cachedData.GetAccessTokens(); if (!getUserTokens.ContainsKey(authToken)) { //Get Data from DB cachedData.GetAccessToken(authToken); getUserTokens = cachedData.GetAccessTokens(); } return CheckAccessToken(getUserTokens, authToken, out errorResponse); } else { errorResponse.Add(HttpStatusCode.Gone, "Access token not found."); } return false; }