From bf5e56c04fe3aa4abc5ead1e27f43c488c649667 Mon Sep 17 00:00:00 2001 From: cflakes Date: Tue, 23 Mar 2010 16:12:38 +0000 Subject: [PATCH] WebMods: Add an error message for users that have cookie support turned off. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1839 726aef4b-f618-498e-8847-2d620e286838 --- WebModules.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/WebModules.cpp b/WebModules.cpp index b1e4de46..1137dafe 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -87,7 +87,7 @@ void CWebAuth::AcceptedLogin(CUser& User) { m_pWebSock->SetLoggedIn(true); m_pWebSock->UnPauseRead(); - m_pWebSock->Redirect("/"); + m_pWebSock->Redirect("/?cookie_check=true"); DEBUG("Successful login attempt ==> USER [" + User.GetUserName() + "] ==> SESSION [" + spSession->GetId() + "]"); } @@ -103,7 +103,7 @@ void CWebAuth::RefusedLogin(const CString& sReason) { m_pWebSock->SetLoggedIn(false); m_pWebSock->UnPauseRead(); - m_pWebSock->Redirect("/"); + m_pWebSock->Redirect("/?cookie_check=true"); DEBUG("UNSUCCESSFUL login attempt ==> REASON [" + sReason + "] ==> SESSION [" + spSession->GetId() + "]"); } @@ -516,6 +516,8 @@ void CWebSock::OnPageRequest(const CString& sURI) { } CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CString& sPageRet) { + bool bNoCookie = (GetCookie("SessionId").empty()); + m_spSession = GetSession(); SetCookie("SessionId", m_spSession->GetId()); @@ -526,6 +528,9 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS // Handle the static pages that don't require a login if (sURI == "/") { + if(!m_bLoggedIn && GetParam("cookie_check").ToBool() && bNoCookie) { + m_spSession->AddError("Your browser does not have cookies enabled for this site!"); + } return PrintTemplate("index", sPageRet); } else if (sURI == "/favicon.ico") { return PrintStaticFile("/pub/favicon.ico", sPageRet);