Improved permission checks.

master
Josef Rokos 8 years ago
parent b0f129f38d
commit 328352f91a

@ -174,6 +174,13 @@ private slots:
protected:
virtual void handleNewRecord() override
{
PermissionEvaluator permEv;
if (!permEv.hasPermission(pluginId(), PERM_ADD))
{
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to add new record."));
return;
}
if (m_form == NULL)
{
Q_ASSERT(false);
@ -187,6 +194,13 @@ protected:
virtual void handleEditRecord() override
{
PermissionEvaluator permEv;
if (!permEv.hasPermission(pluginId(), PERM_EDIT))
{
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to edit record."));
return;
}
if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0)
{
Q_ASSERT(false);
@ -200,6 +214,13 @@ protected:
void handleDeleteRecord() override
{
PermissionEvaluator permEv;
if (!permEv.hasPermission(pluginId(), PERM_DELETE))
{
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to delete record."));
return;
}
m_permissionDenied = false;
connectService();
if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0)

@ -8,6 +8,7 @@
#include <QStringList>
#include <QIcon>
#include <QTranslator>
#include <QMessageBox>
#include "service.h"
#include "igridform.h"
@ -51,6 +52,13 @@ public:
virtual void init(const QJsonObject &metaData) = 0;
virtual QWidget *ui() {
PermissionEvaluator permEv;
if (!permEv.hasPermission(pluginId(), PERM_READ))
{
QMessageBox::critical(m_ui, QObject::tr("Permission denied"), QObject::tr("You don't have permission to open this plugin."));
return NULL;
}
IGridForm *form = qobject_cast<IGridForm*>(m_ui);
bool filled = true;

@ -6,6 +6,8 @@
#include "iplugin.h"
#include "iform.h"
#include <QMessageBox>
SettingsForm::SettingsForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsForm)
@ -39,6 +41,12 @@ void SettingsForm::on_buttonBox_accepted()
void SettingsForm::accept()
{
if (!Context::instance().currentUser()->isAdmin())
{
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to save settings."));
return;
}
for (int i = 0; i < ui->tabWidget->count(); i++)
{
IForm *tab = qobject_cast<IForm*>(ui->tabWidget->widget(i));

@ -77,12 +77,12 @@ bool UserForm::bindOtherToData()
}
void UserForm::on_password_textChanged(const QString &arg1)
void UserForm::on_password_textChanged(const QString &)
{
m_passChanged = true;
}
void UserForm::on_retypePassword_textChanged(const QString &arg1)
void UserForm::on_retypePassword_textChanged(const QString &)
{
m_passChanged = true;
}

@ -24,6 +24,12 @@ QIcon Shop::pluginIcon()
QWidget *Shop::ui()
{
QWidget *uiWidget = IPlugin::ui();
if (uiWidget == NULL)
{
return NULL;
}
qobject_cast<ShopForm*>(uiWidget)->loadLast();
qobject_cast<ShopForm*>(uiWidget)->fillRaceiptCombo();
qobject_cast<ShopForm*>(uiWidget)->loadButtons();

Loading…
Cancel
Save