mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Merge pull request #2665 from alphagov/fix-showing-name-of-service-you-dont-belong-to
Hide ‘back to …’ link if it’s not your service
This commit is contained in:
@@ -151,8 +151,11 @@ class User(UserMixin):
|
||||
def has_permission_for_service(self, service_id, permission):
|
||||
return permission in self._permissions.get(service_id, [])
|
||||
|
||||
def belongs_to_service(self, service_id):
|
||||
return str(service_id) in self.services
|
||||
|
||||
def belongs_to_service_or_403(self, service_id):
|
||||
if str(service_id) not in self.services:
|
||||
if not self.belongs_to_service(service_id):
|
||||
abort(403)
|
||||
|
||||
def is_locked(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block fullwidth_content %}
|
||||
<div id="content">
|
||||
{% if current_service and current_user.is_authenticated %}
|
||||
{% if current_service and current_user.is_authenticated and current_user.belongs_to_service(current_service.id) %}
|
||||
<div class="navigation-service">
|
||||
<a href="{{ url_for('main.show_accounts_or_dashboard') }}">Back to {{ current_service.name }}</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user