- /* Only allow AUTHENTICATE on unregistered clients */
- std::deque<std::string> params;
- params.push_back("*");
- params.push_back("AUTHENTICATE");
- params.push_back(user->uuid);
+ this->state = SASL_DONE;
+ this->result = this->GetSaslResult(msg[3]);
+ }
+
+ break;
+ case SASL_DONE:
+ break;
+ default:
+ ServerInstance->Logs->Log("m_sasl", LOG_DEFAULT, "WTF: SaslState is not a known state (%d)", this->state);
+ break;
+ }
+
+ return this->state;
+ }
+
+ void Abort(void)
+ {
+ this->state = SASL_DONE;
+ this->result = SASL_ABORT;
+ }
+
+ bool SendClientMessage(const std::vector<std::string>& parameters)
+ {
+ if (this->state != SASL_COMM)
+ return true;
+
+ parameterlist params;
+ params.push_back(sasl_target);
+ params.push_back("SASL");
+ params.push_back(this->user->uuid);
+ params.push_back(this->agent);
+ params.push_back("C");
+
+ params.insert(params.end(), parameters.begin(), parameters.end());
+
+ SendSASL(params);
+
+ if (parameters[0][0] == '*')
+ {
+ this->Abort();
+ return false;
+ }
+
+ return true;
+ }
+
+ void AnnounceState(void)
+ {
+ if (this->state_announced)
+ return;
+
+ switch (this->result)
+ {
+ case SASL_OK:
+ this->user->WriteNumeric(903, "%s :SASL authentication successful", this->user->nick.c_str());
+ break;
+ case SASL_ABORT:
+ this->user->WriteNumeric(906, "%s :SASL authentication aborted", this->user->nick.c_str());
+ break;
+ case SASL_FAIL:
+ this->user->WriteNumeric(904, "%s :SASL authentication failed", this->user->nick.c_str());
+ break;
+ default:
+ break;
+ }