X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcoreauthhandler.cpp;h=1ea6305ec7bd8f2ee65a7950bb639fb9c7a2e5ce;hb=a95ad2de573027f9bee36db972bcae4195168d0c;hp=ee505a7455e3af870fbe3939ca5104d3a4c6c10f;hpb=af29862368978b94f00f13b957f685d78c7e8104;p=quassel.git diff --git a/src/core/coreauthhandler.cpp b/src/core/coreauthhandler.cpp index ee505a74..1ea6305e 100644 --- a/src/core/coreauthhandler.cpp +++ b/src/core/coreauthhandler.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -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())));