8#include <Cutelyst/Controller>
9#include <Cutelyst/Dispatcher>
10#include <Cutelyst/Plugins/Authentication/authentication.h>
129 return AroundExecute;
135 Q_UNUSED(application)
138 d->actionReverse = args.value(
QLatin1String(
"reverse")).toString();
142 qFatal(
"RoleACL: Action %s requires at least one RequiresRole or AllowedRole attribute",
143 qPrintable(d->actionReverse));
146 for (
const QString &role : required) {
147 d->requiresRole.append(role);
151 for (
const QString &role : allowed) {
152 d->allowedRole.append(role);
156 auto it = attributes.constFind(
QLatin1String(
"ACLDetachTo"));
157 if (it == attributes.constEnd() || it.value().isEmpty()) {
158 qFatal(
"RoleACL: Action %s requires the ACLDetachTo(<action>) attribute",
159 qPrintable(d->actionReverse));
161 d->aclDetachTo = it.value();
190 for (
const QString &role : required) {
196 for (
const QString &role : allowed) {
201 }
else if (!required.
isEmpty()) {
202 for (
const QString &role : required) {
208 }
else if (!allowed.
isEmpty()) {
209 for (
const QString &role : allowed) {
224 d->detachTo = controller->
actionFor(d->aclDetachTo);
229 "RoleACL: Action '%s' requires a valid action set on the ACLDetachTo(%s) attribute",
230 qPrintable(d->actionReverse),
231 qPrintable(d->aclDetachTo));
238#include "moc_roleacl.cpp"
The Cutelyst Application.
static AuthenticationUser user(Context *c)
Component(QObject *parent=nullptr)
virtual bool aroundExecute(Context *c, QStack< Component * > stack)
void detach(Action *action=nullptr)
Cutelyst Controller base class
Action * actionFor(const QString &name) const
Action * getActionByPath(const QString &path) const
bool canVisit(Context *c) const
virtual bool init(Application *application, const QVariantHash &args) override
RoleACL(QObject *parent=nullptr)
virtual bool aroundExecute(Context *c, QStack< Component * > stack) override
virtual Modifiers modifiers() const override
virtual bool dispatcherReady(const Dispatcher *dispatcher, Controller *controller) override
The Cutelyst namespace holds all public Cutelyst API.
QMultiMap< QString, QString > ParamsMultiMap
bool isEmpty() const const
QObject * parent() const const
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
QStringList toStringList() const const