/// <inheritdoc/> public bool IsValidCode(string requestedCode, out IAuthenticatedSession session) { if (this.dataService.IsValidCode(requestedCode)) { var accessToken = new ValidCodeAccess(requestedCode); this.cookieToCode[accessToken.Cookie] = accessToken; session = accessToken; return(true); } session = null; return(false); }
/// <summary> /// Verify if the cookie is known /// </summary> /// <param name="cookie">the cookie of the request</param> /// <param name="code">the code for the cookie</param> /// <returns>true if the cookie was valid and the code is </returns> public bool IsValidCookie(string cookie, out IAuthenticatedSession session) { if (!this.cookieToCode.TryGetValue(cookie, out var accessToken)) { session = null; return(false); } if (DateTime.UtcNow - accessToken.ValidationTime > TimeSpan.FromHours(2)) { this.cookieToCode.Remove(cookie); session = null; return(false); } session = accessToken; return(true); }