summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nickcore.cpp39
-rw-r--r--src/nickserv.cpp7
-rw-r--r--src/users.cpp57
3 files changed, 102 insertions, 1 deletions
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 4863d3244..e83d46c47 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -129,3 +129,42 @@ void NickCore::ClearAccess()
FOREACH_MOD(I_OnNickClearAccess, OnNickClearAccess(this));
this->access.clear();
}
+
+void NickCore::AddCert(const Anope::string &entry)
+{
+ this->cert.push_back(entry);
+ FOREACH_MOD(I_OnNickAddCert, OnNickAddCert(this, entry));
+}
+
+Anope::string NickCore::GetCert(unsigned entry) const
+{
+ if (this->cert.empty() || entry >= this->cert.size())
+ return "";
+ return this->cert[entry];
+}
+
+bool NickCore::FindCert(const Anope::string &entry)
+{
+ for (unsigned i = 0, end = this->cert.size(); i < end; ++i)
+ if (this->cert[i] == entry)
+ return true;
+
+ return false;
+}
+
+void NickCore::EraseCert(const Anope::string &entry)
+{
+ for (unsigned i = 0, end = this->cert.size(); i < end; ++i)
+ if (this->cert[i] == entry)
+ {
+ FOREACH_MOD(I_OnNickEraseCert, OnNickEraseCert(this, entry));
+ this->cert.erase(this->cert.begin() + i);
+ break;
+ }
+}
+
+void NickCore::ClearCert()
+{
+ FOREACH_MOD(I_OnNickClearCert, OnNickClearCert(this));
+ this->cert.clear();
+}
diff --git a/src/nickserv.cpp b/src/nickserv.cpp
index aed4cc973..fb1e52819 100644
--- a/src/nickserv.cpp
+++ b/src/nickserv.cpp
@@ -185,7 +185,12 @@ int validate_user(User *u)
u->Collide(na);
return 0;
}
-
+ if (!u->IsIdentified() && !u->fingerprint.empty() && na->nc->FindCert(u->fingerprint))
+ {
+ u->SendMessage(NickServ, _("SSL Fingerprint accepted, you are now identified"));
+ u->Identify(na);
+ return 1;
+ }
if (!na->nc->HasFlag(NI_SECURE) && u->IsRecognized())
{
na->last_seen = Anope::CurTime;
diff --git a/src/users.cpp b/src/users.cpp
index e343e3ad2..4b6e7368e 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -334,6 +334,63 @@ void User::Collide(NickAlias *na)
kill_user(Config->s_NickServ, this, "Services nickname-enforcer kill");
}
+/** Identify the user to the Nick
+ * updates last_seen, logs the user in,
+ * send messages, checks for mails, set vhost and more
+ * @param the NickAlias
+ */
+void User::Identify(NickAlias *na)
+{
+ if (!na)
+ {
+ Log() << "User::Identify() called with NULL pointer";
+ return;
+ }
+
+ if (this->nick.equals_ci(na->nick))
+ {
+ Anope::string last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
+ na->last_usermask = last_usermask;
+ na->last_realname = this->realname;
+ na->last_seen = Anope::CurTime;
+ }
+
+ this->Login(na->nc);
+ ircdproto->SendAccountLogin(this, this->Account());
+ ircdproto->SetAutoIdentificationToken(this);
+
+ if (na->nc->HasFlag(NI_UNCONFIRMED) == false)
+ this->SetMode(NickServ, UMODE_REGISTERED);
+ if (ircd->vhost)
+ do_on_id(this);
+ if (Config->NSModeOnID)
+ do_setmodes(this);
+
+ FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
+
+ if (Config->NSForceEmail && na->nc->email.empty())
+ {
+ this->SendMessage(NickServ, _("You must now supply an e-mail for your nick.\n"
+ "This e-mail will allow you to retrieve your password in\n"
+ "case you forget it."));
+ this->SendMessage(NickServ, _("Type \002%R%s SET EMAIL \037e-mail\037\002 in order to set your e-mail.\n"
+ "Your privacy is respected; this e-mail won't be given to\n"
+ "any third-party person."), NickServ->nick.c_str());
+ }
+
+ if (na->nc->HasFlag(NI_UNCONFIRMED))
+ {
+ this->SendMessage(NickServ, _("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you when you registered."));
+ time_t time_registered = Anope::CurTime - na->time_registered;
+ if (Config->NSUnconfirmedExpire > time_registered)
+ this->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s"), duration(Config->NSUnconfirmedExpire - time_registered).c_str());
+ }
+
+ check_memos(this);
+
+}
+
+
/** Login the user to a NickCore
* @param core The account the user is useing
*/