From a5dcb3ff77fec4a168698ceb48da911b7af54da9 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 7 Jul 2008 18:36:26 +0000 Subject: [PATCH] webadmin: Use the new CZNC::AuthUser() API git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1116 726aef4b-f618-498e-8847-2d620e286838 --- modules/webadmin.cpp | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 92ec0764..a5ea5ab6 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -264,35 +264,13 @@ void CWebAdminSock::PrintPage(CString& sPageRet, const CString& sTmplName) { bool CWebAdminSock::OnLogin(const CString& sUser, const CString& sPass) { m_spAuth = new CWebAdminAuth(this, sUser, sPass); - if (CZNC::Get().GetModules().OnLoginAttempt(m_spAuth)) { - if (IsLoggedIn()) { - return true; - } + // Some authentication module could need some time, block this socket + // until then. CWebAdminAuth will UnPauseRead(). + PauseRead(); + CZNC::Get().AuthUser(m_spAuth); - PauseRead(); - - return false; - } - - CUser* pUser = CZNC::Get().FindUser(GetUser()); - - if (pUser) { - CString sHost = GetRemoteIP(); - - if (pUser->IsHostAllowed(sHost) && pUser->CheckPass(GetPass())) { - if (pUser->IsAdmin()) { - m_bAdmin = true; - } else { - m_pUser = pUser; - } - - m_pSessionUser = pUser; - - return true; - } - } - - return false; + // If CWebAdminAuth already set this, don't change it. + return IsLoggedIn(); } void CWebAdminSock::ListUsersPage(CString& sPageRet) { @@ -1184,6 +1162,7 @@ void CWebAdminAuth::AcceptLogin(CUser& User) { void CWebAdminAuth::RefuseLogin(const CString& sReason) { if (m_pWebAdminSock) { + m_pWebAdminSock->SetLoggedIn(false); m_pWebAdminSock->UnPauseRead(); } }