added form to edit user roles #4 (#18)

added voter to handle user profile access
using Security annotation to handle access authorization
This commit is contained in:
Kevin Papst
2018-01-05 14:10:08 +01:00
committed by GitHub
parent ea030ca199
commit 96de95b7c9
8 changed files with 384 additions and 104 deletions

View File

@@ -354,6 +354,10 @@
<source>profile.password</source>
<target>Passwort</target>
</trans-unit>
<trans-unit id="profile.roles">
<source>profile.roles</source>
<target>Rollen</target>
</trans-unit>
<!--
Admin: Timesheet

View File

@@ -16,9 +16,15 @@
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li {% if tab == "charts" %}class="active"{% endif %}><a href="#charts" data-toggle="tab" aria-expanded="true">{{ 'profile.tab_monthly'|trans }}</a></li>
{% if form %}
<li {% if tab == "profile" %}class="active"{% endif %}><a href="#profile" data-toggle="tab" aria-expanded="false">{{ 'profile.settings'|trans }}</a></li>
<li {% if tab == "password" %}class="active"{% endif %}><a href="#password" data-toggle="tab" aria-expanded="false">{{ 'profile.password'|trans }}</a></li>
{% endif %}
{% if form_password %}
<li {% if tab == "password" %}class="active"{% endif %}><a href="#password" data-toggle="tab" aria-expanded="false">{{ 'profile.password'|trans }}</a></li>
{% endif %}
{% if form_roles %}
<li {% if tab == "roles" %}class="active"{% endif %}><a href="#roles" data-toggle="tab" aria-expanded="false">{{ 'profile.roles'|trans }}</a></li>
{% endif %}
</ul>
<div class="tab-content">
<div class="tab-pane {% if tab == "charts" %}active{% endif %}" id="charts">
@@ -88,18 +94,30 @@
{% endfor %}
</div>
<div class="tab-pane {% if tab == "profile" %}active{% endif %}" id="profile">
{{ form_start(form) }}
{{ form_widget(form) }}
{% if form %}
<div class="tab-pane {% if tab == "profile" %}active{% endif %}" id="profile">
{{ form_start(form) }}
{{ form_widget(form) }}
<input type="submit" value="{{ 'action.save'|trans }}" class="btn btn-primary" />
{{ form_end(form) }}
</div>
{% endif %}
{% if form_password %}
<div class="tab-pane {% if tab == "password" %}active{% endif %}" id="password">
{{ form_start(form_password) }}
{{ form_widget(form_password) }}
<input type="submit" value="{{ 'action.save'|trans }}" class="btn btn-primary" />
{{ form_end(form) }}
</div>
<div class="tab-pane {% if tab == "password" %}active{% endif %}" id="password">
{{ form_start(form_password) }}
{{ form_widget(form_password) }}
<input type="submit" value="{{ 'action.save'|trans }}" class="btn btn-primary" />
{{ form_end(form_password) }}
</div>
{{ form_end(form_password) }}
</div>
{% endif %}
{% if form_roles %}
<div class="tab-pane {% if tab == "roles" %}active{% endif %}" id="roles">
{{ form_start(form_roles) }}
{{ form_widget(form_roles) }}
<input type="submit" value="{{ 'action.save'|trans }}" class="btn btn-primary" />
{{ form_end(form_roles) }}
</div>
{% endif %}
</div>
</div>
</div>

View File

@@ -24,6 +24,20 @@ services:
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
# security voter to check user-profile access
app.voter.user:
class: AppBundle\Voter\UserVoter
arguments: ["@security.access.decision_manager"]
tags:
- { name: security.voter }
# form to edit user roles
app.admin.user_profile_roles:
class: AppBundle\Form\UserRolesType
arguments: ["%security.role_hierarchy.roles%"]
tags:
- { name: form.type }
# event-listener to populate the navigation
app.menu_builder:
class: AppBundle\EventListener\MenuBuilder