Unify some of the webadmin and client authentication code in CZNC::AuthUser()

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1114 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-07-07 18:34:32 +00:00
parent 7965a12bd0
commit 0bd4927d2c
2 changed files with 34 additions and 0 deletions
+29
View File
@@ -1693,6 +1693,35 @@ void CZNC::UpdateTrafficStats() {
}
}
void CZNC::AuthUser(CSmartPtr<CAuthBase> AuthClass) {
#ifdef _MODULES
// TODO unless the auth module calls it, CUser::IsHostAllowed() is not honoured
if (GetModules().OnLoginAttempt(AuthClass)) {
return;
}
#endif
CUser* pUser = GetUser(AuthClass->GetUsername());
if (!pUser || !pUser->CheckPass(AuthClass->GetPassword())) {
if (pUser) {
pUser->PutStatus("Another client attempted to login as you, with a bad password.");
}
AuthClass->RefuseLogin("Invalid Password");
return;
}
CString sHost = AuthClass->GetRemoteIP();
if (!pUser->IsHostAllowed(sHost)) {
AuthClass->RefuseLogin("Your host [" + sHost + "] is not allowed");
return;
}
AuthClass->AcceptLogin(*pUser);
}
class CConnectUserTimer : public CCron {
public:
CConnectUserTimer(int iSecs) : CCron() {