mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
Merge commit 'refs/pull/665/head' of github.com:znc/znc
This commit is contained in:
+2
-2
@@ -67,7 +67,7 @@ using std::vector;
|
||||
}
|
||||
|
||||
CClient::~CClient() {
|
||||
if (!m_spAuth.IsNull()) {
|
||||
if (m_spAuth) {
|
||||
CClientAuth* pAuth = (CClientAuth*) &(*m_spAuth);
|
||||
pAuth->Invalidate();
|
||||
}
|
||||
@@ -631,7 +631,7 @@ void CClient::AuthUser() {
|
||||
if (!m_bGotNick || !m_bGotUser || !m_bGotPass || m_bInCap || IsAttached())
|
||||
return;
|
||||
|
||||
m_spAuth = new CClientAuth(this, m_sUser, m_sPass);
|
||||
m_spAuth = std::make_shared<CClientAuth>(this, m_sUser, m_sPass);
|
||||
|
||||
CZNC::Get().AuthUser(m_spAuth);
|
||||
}
|
||||
|
||||
+2
-2
@@ -756,7 +756,7 @@ bool CModule::PutModNotice(const CString& sLine) {
|
||||
CModule::EModRet CModule::OnAddUser(CUser& User, CString& sErrorRet) { return CONTINUE; }
|
||||
CModule::EModRet CModule::OnDeleteUser(CUser& User) { return CONTINUE; }
|
||||
void CModule::OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned short uPort) {}
|
||||
CModule::EModRet CModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
|
||||
CModule::EModRet CModule::OnLoginAttempt(std::shared_ptr<CAuthBase> Auth) { return CONTINUE; }
|
||||
void CModule::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {}
|
||||
CModule::EModRet CModule::OnUnknownUserRaw(CClient* pClient, CString& sLine) { return CONTINUE; }
|
||||
void CModule::OnClientCapLs(CClient* pClient, SCString& ssCaps) {}
|
||||
@@ -920,7 +920,7 @@ bool CModules::OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CModules::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
|
||||
bool CModules::OnLoginAttempt(std::shared_ptr<CAuthBase> Auth) {
|
||||
MODHALTCHK(OnLoginAttempt(Auth));
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -581,14 +581,14 @@ bool CTemplate::Print(const CString& sFileName, ostream& oOut) {
|
||||
}
|
||||
} else if (bNotFound) {
|
||||
// Unknown tag that isn't being skipped...
|
||||
vector<CSmartPtr<CTemplateTagHandler> >& vspTagHandlers = GetTagHandlers();
|
||||
vector<std::shared_ptr<CTemplateTagHandler> >& vspTagHandlers = GetTagHandlers();
|
||||
|
||||
if (!vspTagHandlers.empty()) { // @todo this should go up to the top to grab handlers
|
||||
CTemplate* pTmpl = GetCurTemplate();
|
||||
CString sCustomOutput;
|
||||
|
||||
for (unsigned int j = 0; j < vspTagHandlers.size(); j++) {
|
||||
CSmartPtr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
|
||||
std::shared_ptr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
|
||||
|
||||
if (spTagHandler->HandleTag(*pTmpl, sAction, sArgs, sCustomOutput)) {
|
||||
sOutput += sCustomOutput;
|
||||
@@ -826,14 +826,14 @@ CString CTemplate::GetValue(const CString& sArgs, bool bFromIf) {
|
||||
sRet = (it != end()) ? it->second : "";
|
||||
}
|
||||
|
||||
vector<CSmartPtr<CTemplateTagHandler> >& vspTagHandlers = GetTagHandlers();
|
||||
vector<std::shared_ptr<CTemplateTagHandler> >& vspTagHandlers = GetTagHandlers();
|
||||
|
||||
if (!vspTagHandlers.empty()) { // @todo this should go up to the top to grab handlers
|
||||
CTemplate* pTmpl = GetCurTemplate();
|
||||
|
||||
if (sRet.empty()) {
|
||||
for (unsigned int j = 0; j < vspTagHandlers.size(); j++) {
|
||||
CSmartPtr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
|
||||
std::shared_ptr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
|
||||
CString sCustomOutput;
|
||||
|
||||
if (!bFromIf && spTagHandler->HandleVar(*pTmpl, sArgs.Token(0), sArgs.Token(1, true), sCustomOutput)) {
|
||||
@@ -847,7 +847,7 @@ CString CTemplate::GetValue(const CString& sArgs, bool bFromIf) {
|
||||
}
|
||||
|
||||
for (unsigned int j = 0; j < vspTagHandlers.size(); j++) {
|
||||
CSmartPtr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
|
||||
std::shared_ptr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
|
||||
|
||||
if (spTagHandler->HandleValue(*pTmpl, sRet, msArgs)) {
|
||||
break;
|
||||
|
||||
+11
-11
@@ -153,7 +153,7 @@ void CWebSessionMap::FinishUserSessions(const CUser& User) {
|
||||
|
||||
void CWebAuth::AcceptedLogin(CUser& User) {
|
||||
if (m_pWebSock) {
|
||||
CSmartPtr<CWebSession> spSession = m_pWebSock->GetSession();
|
||||
std::shared_ptr<CWebSession> spSession = m_pWebSock->GetSession();
|
||||
|
||||
spSession->SetUser(&User);
|
||||
|
||||
@@ -167,7 +167,7 @@ void CWebAuth::AcceptedLogin(CUser& User) {
|
||||
|
||||
void CWebAuth::RefusedLogin(const CString& sReason) {
|
||||
if (m_pWebSock) {
|
||||
CSmartPtr<CWebSession> spSession = m_pWebSock->GetSession();
|
||||
std::shared_ptr<CWebSession> spSession = m_pWebSock->GetSession();
|
||||
|
||||
spSession->AddError("Invalid login!");
|
||||
spSession->SetUser(NULL);
|
||||
@@ -188,11 +188,11 @@ void CWebAuth::Invalidate() {
|
||||
CWebSock::CWebSock(const CString& sURIPrefix) : CHTTPSock(NULL, sURIPrefix) {
|
||||
m_bPathsSet = false;
|
||||
|
||||
m_Template.AddTagHandler(new CZNCTagHandler(*this));
|
||||
m_Template.AddTagHandler(std::make_shared<CZNCTagHandler>(*this));
|
||||
}
|
||||
|
||||
CWebSock::~CWebSock() {
|
||||
if (!m_spAuth.IsNull()) {
|
||||
if (m_spAuth) {
|
||||
m_spAuth->Invalidate();
|
||||
}
|
||||
|
||||
@@ -819,13 +819,13 @@ static inline bool compareLastActive(const std::pair<const CString, CWebSession
|
||||
return first.second->GetLastActive() < second.second->GetLastActive();
|
||||
}
|
||||
|
||||
CSmartPtr<CWebSession> CWebSock::GetSession() {
|
||||
if (!m_spSession.IsNull()) {
|
||||
std::shared_ptr<CWebSession> CWebSock::GetSession() {
|
||||
if (m_spSession) {
|
||||
return m_spSession;
|
||||
}
|
||||
|
||||
const CString sCookieSessionId = GetRequestCookie("SessionId");
|
||||
CSmartPtr<CWebSession> *pSession = Sessions.m_mspSessions.GetItem(sCookieSessionId);
|
||||
std::shared_ptr<CWebSession> *pSession = Sessions.m_mspSessions.GetItem(sCookieSessionId);
|
||||
|
||||
if (pSession != NULL) {
|
||||
// Refresh the timeout
|
||||
@@ -855,7 +855,7 @@ CSmartPtr<CWebSession> CWebSock::GetSession() {
|
||||
DEBUG("Auto generated session: [" + sSessionID + "]");
|
||||
} while (Sessions.m_mspSessions.HasItem(sSessionID));
|
||||
|
||||
CSmartPtr<CWebSession> spSession(new CWebSession(sSessionID, GetRemoteIP()));
|
||||
std::shared_ptr<CWebSession> spSession(new CWebSession(sSessionID, GetRemoteIP()));
|
||||
Sessions.m_mspSessions.AddItem(spSession->GetId(), spSession);
|
||||
|
||||
m_spSession = spSession;
|
||||
@@ -864,13 +864,13 @@ CSmartPtr<CWebSession> CWebSock::GetSession() {
|
||||
}
|
||||
|
||||
CString CWebSock::GetCSRFCheck() {
|
||||
CSmartPtr<CWebSession> pSession = GetSession();
|
||||
std::shared_ptr<CWebSession> pSession = GetSession();
|
||||
return pSession->GetId().MD5();
|
||||
}
|
||||
|
||||
bool CWebSock::OnLogin(const CString& sUser, const CString& sPass) {
|
||||
DEBUG("=================== CWebSock::OnLogin()");
|
||||
m_spAuth = new CWebAuth(this, sUser, sPass);
|
||||
m_spAuth = std::make_shared<CWebAuth>(this, sUser, sPass);
|
||||
|
||||
// Some authentication module could need some time, block this socket
|
||||
// until then. CWebAuth will UnPauseRead().
|
||||
@@ -889,7 +889,7 @@ Csock* CWebSock::GetSockObj(const CString& sHost, unsigned short uPort) {
|
||||
}
|
||||
|
||||
CString CWebSock::GetSkinName() {
|
||||
CSmartPtr<CWebSession> spSession = GetSession();
|
||||
std::shared_ptr<CWebSession> spSession = GetSession();
|
||||
|
||||
if (spSession->IsLoggedIn() && !spSession->GetUser()->GetSkinName().empty()) {
|
||||
return spSession->GetUser()->GetSkinName();
|
||||
|
||||
+1
-1
@@ -1771,7 +1771,7 @@ CZNC::TrafficStatsMap CZNC::GetTrafficStats(TrafficStatsPair &Users,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CZNC::AuthUser(CSmartPtr<CAuthBase> AuthClass) {
|
||||
void CZNC::AuthUser(std::shared_ptr<CAuthBase> AuthClass) {
|
||||
// TODO unless the auth module calls it, CUser::IsHostAllowed() is not honoured
|
||||
bool bReturn = false;
|
||||
GLOBALMODULECALL(OnLoginAttempt(AuthClass), &bReturn);
|
||||
|
||||
Reference in New Issue
Block a user