9 #include <Cutelyst/Plugins/Authentication/authentication.h>
10 #include <Cutelyst/Controller>
11 #include <Cutelyst/Dispatcher>
119 return AroundExecute;
125 Q_UNUSED(application)
131 qFatal(
"RoleACL: Action %s requires at least one RequiresRole or AllowedRole attribute", qPrintable(d->actionReverse));
134 for (
const QString &role : required) {
135 d->requiresRole.
append(role);
139 for (
const QString &role : allowed) {
140 d->allowedRole.
append(role);
144 auto it = attributes.constFind(
QLatin1String(
"ACLDetachTo"));
145 if (it == attributes.constEnd() || it.value().isEmpty()) {
146 qFatal(
"RoleACL: Action %s requires the ACLDetachTo(<action>) attribute", qPrintable(d->actionReverse));
148 d->aclDetachTo = it.value();
176 for (
const QString &role : required) {
182 for (
const QString &role : allowed) {
187 }
else if (!required.
isEmpty()) {
188 for (
const QString &role : required) {
194 }
else if (!allowed.
isEmpty()) {
195 for (
const QString &role : allowed) {
210 d->detachTo = controller->
actionFor(d->aclDetachTo);
214 qFatal(
"RoleACL: Action '%s' requires a valid action set on the ACLDetachTo(%s) attribute",
215 qPrintable(d->actionReverse), qPrintable(d->aclDetachTo));
222 #include "moc_roleacl.cpp"
The Cutelyst Application.
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(const QString &name) const
Action * getActionByPath(const QString &path) const
User role-based authorization action class.
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.
void append(const T &value)
bool isEmpty() const const
const T value(const Key &key, const T &defaultValue) const const
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
QStringList toStringList() const const