mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #764, improved JSON response with messages for JSON authentication service
This commit is contained in:
committed by
Roland Winklmeier
parent
67fdfd228a
commit
03b5f9ce2c
@@ -121,16 +121,23 @@ namespace BlackCore
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject jsonObj(Json::jsonObjectFromString(json));
|
|
||||||
CAuthenticatedUser user(CAuthenticatedUser::fromDatabaseJson(jsonObj));
|
|
||||||
|
|
||||||
CStatusMessageList msgs;
|
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
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())
|
if (!user.isAuthenticated() || !user.isValid())
|
||||||
|
{
|
||||||
|
if (!msgs.hasErrorMessages())
|
||||||
{
|
{
|
||||||
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Cannot login, user or password wrong"));
|
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Cannot login, user or password wrong"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!user.isEnabled())
|
if (!user.isEnabled())
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ namespace BlackGui
|
|||||||
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
|
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
|
||||||
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
|
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
|
||||||
connect(&m_loginService, &CDatabaseAuthenticationService::userAuthenticationFinished, this, &CDbLoginComponent::ps_AuthenticationFinished);
|
connect(&m_loginService, &CDatabaseAuthenticationService::userAuthenticationFinished, this, &CDbLoginComponent::ps_AuthenticationFinished);
|
||||||
|
connect(ui->le_Password, &QLineEdit::returnPressed, this, &CDbLoginComponent::ps_onLoginClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbLoginComponent::~CDbLoginComponent()
|
CDbLoginComponent::~CDbLoginComponent()
|
||||||
|
|||||||
Reference in New Issue
Block a user