8 #include <Cutelyst/Controller>
9 #include <Cutelyst/Dispatcher>
10 #include <Cutelyst/Plugins/Authentication/authentication.h>
130 return AroundExecute;
136 Q_UNUSED(application)
143 qFatal(
"RoleACL: Action %s requires at least one RequiresRole or AllowedRole attribute",
144 qPrintable(d->actionReverse));
147 for (
const QString &role : required) {
148 d->requiresRole.
append(role);
152 for (
const QString &role : allowed) {
153 d->allowedRole.
append(role);
157 auto it = attributes.constFind(
QLatin1String(
"ACLDetachTo"));
158 if (it == attributes.constEnd() || it.value().isEmpty()) {
159 qFatal(
"RoleACL: Action %s requires the ACLDetachTo(<action>) attribute",
160 qPrintable(d->actionReverse));
162 d->aclDetachTo = it.value();
191 for (
const QString &role : required) {
197 for (
const QString &role : allowed) {
202 }
else if (!required.
isEmpty()) {
203 for (
const QString &role : required) {
209 }
else if (!allowed.
isEmpty()) {
210 for (
const QString &role : allowed) {
225 d->detachTo = controller->
actionFor(d->aclDetachTo);
230 "RoleACL: Action '%s' requires a valid action set on the ACLDetachTo(%s) attribute",
231 qPrintable(d->actionReverse),
232 qPrintable(d->aclDetachTo));
239 #include "moc_roleacl.cpp"
The Cutelyst application.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
static AuthenticationUser user(Context *c)
The Cutelyst Component base class.
virtual bool aroundExecute(Context *c, QStack< Component * > stack)
void detach(Action *action=nullptr)
Cutelyst Controller base class.
Action * actionFor(QStringView name) const
Action * getActionByPath(QStringView path) const
User role-based authorization action role.
bool canVisit(Context *c) const
bool init(Application *application, const QVariantHash &args) override
RoleACL(QObject *parent=nullptr)
bool aroundExecute(Context *c, QStack< Component * > stack) override
Modifiers modifiers() const override
bool dispatcherReady(const Dispatcher *dispatcher, Controller *controller) override
The Cutelyst namespace holds all public Cutelyst API.
void append(QList::parameter_type value)
bool isEmpty() const const
T value(const Key &key, const T &defaultValue) const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QStringList toStringList() const const