X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoreauthhandler.cpp;h=ef24592f7ef6b0104d71c38c22253c7004120e5d;hp=1d46e65cd230270bcb6dd8d6cba90c3f556c3785;hb=8961f348947fc55cc4bc769563684af3f2ea7ccc;hpb=cc6e7c08709c4e761e2fd9c2e322751015497003 diff --git a/src/core/coreauthhandler.cpp b/src/core/coreauthhandler.cpp index 1d46e65c..ef24592f 100644 --- a/src/core/coreauthhandler.cpp +++ b/src/core/coreauthhandler.cpp @@ -20,6 +20,8 @@ #include "coreauthhandler.h" +#include + #ifdef HAVE_SSL # include #endif @@ -29,6 +31,7 @@ CoreAuthHandler::CoreAuthHandler(QTcpSocket* socket, QObject* parent) : AuthHandler(parent) , _peer(nullptr) + , _metricsServer(Core::instance()->metricsServer()) , _magicReceived(false) , _legacy(false) , _clientRegistered(false) @@ -228,7 +231,17 @@ void CoreAuthHandler::handle(const Protocol::Login& msg) // First attempt local auth using the real username and password. // If that fails, move onto the auth provider. - UserId uid = Core::validateUser(msg.user, msg.password); + + // Check to see if the user has the "Database" authenticator configured. + UserId uid = 0; + if (Core::getUserAuthenticator(msg.user) == "Database") { + uid = Core::validateUser(msg.user, msg.password); + } + + // If they did not, *or* if the database login fails, try to use a different authenticator. + // TODO: this logic should likely be moved into Core::authenticateUser in the future. + // Right now a core can only have one authenticator configured; this might be something + // to change in the future. if (uid == 0) { uid = Core::authenticateUser(msg.user, msg.password); } @@ -237,9 +250,15 @@ void CoreAuthHandler::handle(const Protocol::Login& msg) qInfo() << qPrintable(tr("Invalid login attempt from %1 as \"%2\"").arg(socket()->peerAddress().toString(), msg.user)); _peer->dispatch(Protocol::LoginFailed(tr( "Invalid username or password!
The username/password combination you supplied could not be found in the database."))); + if (_metricsServer) { + _metricsServer->addLoginAttempt(msg.user, false); + } return; } _peer->dispatch(Protocol::LoginSuccess()); + if (_metricsServer) { + _metricsServer->addLoginAttempt(uid, true); + } qInfo() << qPrintable(tr("Client %1 initialized and authenticated successfully as \"%2\" (UserId: %3).") .arg(socket()->peerAddress().toString(), msg.user, QString::number(uid.toInt())));