#include "inspircd.h" #include "ssl.h" #include "account.h" #include "base64.h" class NickCore { public: std::string display; std::string hash; std::string pass; std::vector access; }; typedef nspace::hash_map core_hash; core_hash accountlist; bool HasServices() { if (ServerInstance->FindNick("NickServ")) return true; return false; } void LoginUser(User* user, const std::string &accountname, Module *module) { // set the METADATA AccountExtItem *ext = GetAccountExtItem(); ext->set(user, accountname); ServerInstance->PI->SendMetaData(user, "accountname", accountname); if (IS_LOCAL(user)) user->WriteNumeric(900, "%s %s %s :You are now logged in as %s", user->nick.c_str(), user->GetFullHost().c_str(), accountname.c_str(), accountname.c_str()); // set umode +r std::vector parameters; parameters.push_back(user->nick); parameters.push_back("+r"); ServerInstance->SendMode(parameters, ServerInstance->FakeClient); // send AccountEvent AccountEvent(module, user, accountname).Send(); } bool CheckPassword(NickCore *nc, std::string plaintext) { std::string buf; Base64 b64; if (nc->hash == "plain") { buf = b64.Encode(plaintext); if (nc->pass == buf) return true; else return false; } return false; } bool CheckFingerprint(User *user, NickCore *nc, Module *module) { UserCertificateRequest req(user, module); if (req.cert) { for (size_t i = 0; i < nc->access.size(); ++i) { if (nc->access[i] == req.GetFingerprint()) return true; } } return false; }