/project/plugins/acl
/project/plugins/acl
Key | Value | Description |
---|---|---|
enabled | true | true or false to disable the plugin |
priority | 40 | accounts plugin priority |
Name | Description |
---|---|
user_is_logged_in | true or false |
user_email | Logged in email |
user_roles | Looged in user roles |
user_uuid | Logged in user uuid |
AclIsUserLoggedInMiddleware
Name | Description |
---|---|
container | Flextype container |
redirect | Route name to redirect if user is not logged in |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclIsUserLoggedInMiddleware([
'redirect' => 'another.route.name']));
AclAccountsIsUserLoggedInRolesInMiddleware
Name | Description |
---|---|
container | Flextype container |
roles | Roles separated by comma. |
redirect | Route name to redirect if not equal |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclAccountsIsUserLoggedInRolesInMiddleware([
'roles' => 'admin, moderator'
'redirect' => 'another.route.name']));
AclIsUserLoggedInEmailsInMiddleware
Name | Description |
---|---|
container | Flextype container |
emails | Emails separated by comma. |
redirect | Route name to redirect if not equal |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclIsUserLoggedInEmailsInMiddleware([
'emails' => 'jack@flextype.org, jack@flextype.org'
'redirect' => 'another.route.name']));
AclIsUserLoggedInUuidInMiddleware
Name | Description |
---|---|
container | Flextype container |
uuids | Uuids separated by comma. |
redirect | Route name to redirect if not equal |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclIsUserLoggedInUuidInMiddleware([
'uuids' => 'ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2'
'redirect' => 'another.route.name']));
AclIsUserNotLoggedInMiddleware
Name | Description |
---|---|
container | Flextype container |
redirect | Route name to redirect if user is not logged in |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclIsUserNotLoggedInMiddleware([
'redirect' => 'another.route.name']));
AclAccountsIsUserLoggedInRolesNotInMiddleware
Name | Description |
---|---|
container | Flextype container |
roles | Roles separated by comma. |
redirect | Route name to redirect if equal |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclAccountsIsUserLoggedInRolesNotInMiddleware([
'roles' => 'admin, moderator'
'redirect' => 'another.route.name']));
AclIsUserLoggedInEmailsNotInMiddleware
Name | Description |
---|---|
container | Flextype container |
emails | Emails separated by comma. |
redirect | Route name to redirect if equal |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclIsUserLoggedInEmailsNotInMiddleware([
'emails' => 'jack@flextype.org, sam@flextype.org'
'redirect' => 'another.route.name']));
AclIsUserLoggedInUuidNotInMiddleware
Name | Description |
---|---|
container | Flextype container |
uuids | Uuids separated by comma. |
redirect | Route name to redirect if equal |
Example:
flextype()->get('/my-route', 'MyController:method()')
->setName('my.route.name')
->add(new AclIsUserLoggedInUuidNotInMiddleware([
'uuids' => 'ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2'
'redirect' => 'another.route.name']));
You may restrict access for specific users to your entry(entries) in the entry(entries) frontmatter.
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
acl:
accounts:
roles: student, admin
emails: jack@flextype.org, sam@flextype.org
uuids: ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2
---
Lesson content is here...
You may restrict access for specific users to your specific content inside the entry by using shortcodes.
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedIn]
Lesson content is here...
[/userLoggedIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedInRolesIn roles="admin, student"]
Private content here..
[/userLoggedInRolesIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedInUuidIn uuids="ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2"]
Private content here..
[/userLoggedInUuidIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedInEmailIn emails="jack@flextype.org, sam@flextype.org"]
Private content here..
[/userLoggedInEmailIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Hello [userLoggedInEmail]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Hello [userLoggedInEmail], your uuid: [userLoggedInUuid]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Hello [userLoggedInEmail], your uuid: [userLoggedInUuid] and your roles: [userLoggedInRole]
Example:
/project/entries/lessons/lesson-42.md
---
title: [userLoggedIn][userLoggedInEmail] - [/userLoggedIn]Lesson 42
---
Public text here...
[userLoggedIn]
Private content here..
[/userLoggedIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userNotLoggedIn]
Public content for users is here...
[/userNotLoggedIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedInRolesNotIn roles="admin, student"]
Public content for users is here...
[/userLoggedInRolesNotIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedInUuidNotIn uuids="ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2"]
Public content for users is here...
[/userLoggedInUuidNotIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Public text here...
[userLoggedInEmailNotIn emails="jack@flextype.org, sam@flextype.org"]
Public content for users is here...
[/userLoggedInEmailNotIn]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Hello [userLoggedInEmail]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Hello [userLoggedInEmail], your uuid: [userLoggedInUuid]
/project/entries/lessons/lesson-42.md
---
title: Lesson 42
---
Hello [userLoggedInEmail], your uuid: [userLoggedInUuid] and your roles: [userLoggedInRole]
Example:
/project/entries/lessons/lesson-42.md
---
title: [userLoggedIn][userLoggedInEmail] - [/userLoggedIn]Lesson 42
---
Public text here...
[userLoggedIn]
Private content here..
[/userLoggedIn]
You may restrict access for specific users to your specific content inside the TWIG Templates.
{% if flextype.acl.isUserLoggedIn() %}
Private content here..
{% else %}
Public content for users is here...
{% endif %}
{% if flextype.acl.isUserLoggedInRolesIn('admin, student') %}
Private content here..
{% else %}
Public content for users is here...
{% endif %}
{% if flextype.acl.isUserLoggedInUuidIn('ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2') %}
Private content here..
{% else %}
Public content for users is here...
{% endif %}
{% if flextype.acl.isUserLoggedInEmailIn('jack@flextype.org, sam@flextype.org') %}
Public content for users is here...
{% else %}
Public content for users is here...
{% endif %}
Hello {{ flextype.acl.getUserLoggedInEmail() }}
Hello {{ flextype.acl.getUserLoggedInEmail() }},
your uuid: {{ flextype.acl.getUserLoggedInUuid() }}
Hello {{ flextype.acl.getUserLoggedInEmail() }},
your uuid: {{ flextype.acl.getUserLoggedInUuid() }}
and your roles: {{ flextype.acl.getUserLoggedInRoles() }}
You may restrict access for specific users to your specific code in the PHP.
if (flextype('acl')->isUserLoggedIn()) {
// Private code here..
}
if (flextype('acl')->isUserLoggedInRolesIn('admin, student')) {
// Private code here..
}
if (flextype('acl')->isUserLoggedInUuidIn('ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2') {
// Private content here..
}
if (flextype('acl')->isUserLoggedInEmailIn('jack@flextype.org, sam@flextype.org')) {
// Private content here..
}
echo 'Hello ' . flextype('acl')->getUserLoggedInEmail();
echo 'Hello ' . flextype('acl')->getUserLoggedInEmail();
echo 'your uuid: ' . flextype('acl')->getUserLoggedInUuid();
echo 'Hello ' . flextype('acl')->getUserLoggedInEmail();
echo 'your uuid: ' . flextype('acl')->getUserLoggedInUuid();
echo 'and your roles: ' . flextype('acl')->getUserLoggedInRoles();