bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) override { if (sPageName != "index") { // only accept requests to index return false; } if (WebSock.IsPost()) { SetNV("username", WebSock.GetParam("username")); CString sPassword = WebSock.GetParam("password"); if (!sPassword.empty()) { SetNV("password", sPassword); } SetNV(NV_REQUIRE_AUTH, WebSock.GetParam("require_auth")); SetNV(NV_MECHANISMS, WebSock.GetParam("mechanisms")); } Tmpl["Username"] = GetNV("username"); Tmpl["Password"] = GetNV("password"); Tmpl["RequireAuth"] = GetNV(NV_REQUIRE_AUTH); Tmpl["Mechanisms"] = GetMechanismsString(); for (const auto& it : SupportedMechanisms) { CTemplate& Row = Tmpl.AddRow("MechanismLoop"); CString sName(it.szName); Row["Name"] = sName; Row["Description"] = CString(it.szDescription); } return true; }
void OnServerCapResult(const CString& sCap, bool bSuccess) override { if (sCap.Equals("sasl")) { if (bSuccess) { GetMechanismsString().Split(" ", m_Mechanisms); if (m_Mechanisms.empty()) { CheckRequireAuth(); return; } GetNetwork()->GetIRCSock()->PauseCap(); m_Mechanisms.SetIndex(0); PutIRC("AUTHENTICATE " + m_Mechanisms.GetCurrent()); } else { CheckRequireAuth(); } } }
void SetMechanismCommand(const CString& sLine) { CString sMechanisms = sLine.Token(1, true).AsUpper(); if (!sMechanisms.empty()) { VCString vsMechanisms; sMechanisms.Split(" ", vsMechanisms); for (const CString& sMechanism : vsMechanisms) { if (!SupportsMechanism(sMechanism)) { PutModule("Unsupported mechanism: " + sMechanism); return; } } SetNV(NV_MECHANISMS, sMechanisms); } PutModule("Current mechanisms set: " + GetMechanismsString()); }
void SetMechanismCommand(const CString& sLine) { CString sMechanisms = sLine.Token(1, true).AsUpper(); if (!sMechanisms.empty()) { VCString vsMechanisms; sMechanisms.Split(" ", vsMechanisms); for (VCString::const_iterator it = vsMechanisms.begin(); it != vsMechanisms.end(); ++it) { if (!SupportsMechanism(*it)) { PutModule("Unsupported mechanism: " + *it); return; } } SetNV(NV_MECHANISMS, sMechanisms); } PutModule("Current mechanisms set: " + GetMechanismsString()); }
void onServerCapResult(const NoString& cap, bool success) override { if (cap.equals("sasl")) { if (success) { m_Mechanisms = GetMechanismsString().split(" "); if (m_Mechanisms.empty()) { CheckRequireAuth(); return; } network()->ircSocket()->pauseCap(); m_Mechanisms.SetIndex(0); putIrc("AUTHENTICATE " + m_Mechanisms.GetCurrent()); } else { CheckRequireAuth(); } } }
void SetMechanismCommand(const NoString& line) { NoString sMechanisms = No::tokens(line, 1).toUpper(); if (!sMechanisms.empty()) { NoStringVector vsMechanisms = sMechanisms.split(" "); for (NoStringVector::const_iterator it = vsMechanisms.begin(); it != vsMechanisms.end(); ++it) { if (!SupportsMechanism(*it)) { putModule("Unsupported mechanism: " + *it); return; } } NoRegistry registry(this); registry.setValue(NV_MECHANISMS, sMechanisms); } putModule("Current mechanisms set: " + GetMechanismsString()); }