Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
access-to-portal page can now be accessed (as staff member) for other…
Browse files Browse the repository at this point in the history
… users for debug purposes
  • Loading branch information
reinout committed Nov 12, 2015
1 parent e6a3a86 commit 613925e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ <h5>...via organisation membership:</h5>
{% endfor %}

<h2>Filtered: the applicable organisation-role-mappings I can access for this portal</h2>
<h3>...direct access to roles</h3>
<h4>...direct access to roles</h4>
{% for orgrole in view.organisation_roles_explanation.direct_results %}
{{ orgrole }}<br>
{% empty %}
Nothing
{% endfor %}
<h3>...indirect access via role inheritance</h3>
<h4>...indirect access via role inheritance</h4>
{% for orgrole in view.organisation_roles_explanation.indirect_results %}
{{ orgrole }}<br>
{% empty %}
Expand All @@ -76,6 +76,18 @@ <h2>As a final check, the total applicable organisation role mappings I can acce
Nothing
{% endfor %}

<h2>Users that can log into this portal</h2>
<p>The link goes to this same page <b>for that user</b>. Handy for debugging access issues.</p>
<ul>
{% for user_profile in view.user_profiles_for_portal %}
<li>
<a href="{% url 'lizard_auth_server.access_to_portal' portal_pk=view.portal.id user_pk=user_profile.user.id %}">
{{ user_profile.user.username }}
</a>
</li>
{% endfor %}
</ul>

{% endif %}

</div>
Expand Down
5 changes: 5 additions & 0 deletions lizard_auth_server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ def check_settings():
views.AccessToPortalView.as_view(),
name='lizard_auth_server.access_to_portal'
),
url(
r'^access-to-portal/(?P<portal_pk>\d+)/(?P<user_pk>\d+)/$',
views.AccessToPortalView.as_view(),
name='lizard_auth_server.access_to_portal'
),

)

Expand Down
14 changes: 14 additions & 0 deletions lizard_auth_server/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.template.context import RequestContext
Expand Down Expand Up @@ -116,14 +117,27 @@ def title(self):

@cached_property
def profile(self):
if self.request.user.is_staff:
user_id = self.kwargs.get('user_pk')
if user_id:
user = User.objects.get(id=user_id)
return user.get_profile()
return self.request.user.get_profile()

@cached_property
def organisation_roles_explanation(self):
if not self.request.user.is_staff:
return
return self.profile.all_organisation_roles(
self.portal,
return_explanation=True)

@cached_property
def user_profiles_for_portal(self):
if not self.request.user.is_staff:
return
return self.portal.user_profiles.select_related('user')

@cached_property
def my_organisation_roles_for_this_portal(self):
return self.profile.all_organisation_roles(self.portal)
Expand Down

0 comments on commit 613925e

Please sign in to comment.