refs #764, improved JSON response with messages for JSON authentication service

This commit is contained in:
Klaus Basan
2016-09-13 03:53:52 +02:00
committed by Roland Winklmeier
parent 67fdfd228a
commit 03b5f9ce2c
2 changed files with 13 additions and 5 deletions

View File

@@ -121,15 +121,22 @@ namespace BlackCore
return;
}
QJsonObject jsonObj(Json::jsonObjectFromString(json));
CAuthenticatedUser user(CAuthenticatedUser::fromDatabaseJson(jsonObj));
CStatusMessageList msgs;
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
QJsonObject jsonObj(Json::jsonObjectFromString(json));
CAuthenticatedUser user = CAuthenticatedUser::fromDatabaseJson(jsonObj.contains("user") ? jsonObj["user"].toObject() : jsonObj);
CStatusMessageList msgs;
if (jsonObj.contains("messages"))
{
msgs = CStatusMessageList::fromDatabaseJson(jsonObj["messages"].toArray());
msgs.setCategories(cats);
}
if (!user.isAuthenticated() || !user.isValid())
{
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Cannot login, user or password wrong"));
if (!msgs.hasErrorMessages())
{
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Cannot login, user or password wrong"));
}
}
else
{

View File

@@ -54,6 +54,7 @@ namespace BlackGui
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
connect(&m_loginService, &CDatabaseAuthenticationService::userAuthenticationFinished, this, &CDbLoginComponent::ps_AuthenticationFinished);
connect(ui->le_Password, &QLineEdit::returnPressed, this, &CDbLoginComponent::ps_onLoginClicked);
}
CDbLoginComponent::~CDbLoginComponent()