Skip to content

Commit

Permalink
Show error message for echo_attributes when not logged in via SAML
Browse files Browse the repository at this point in the history
This fixes issue #72
  • Loading branch information
knaperek committed Aug 16, 2017
1 parent 5b5577c commit d987dc0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions djangosaml2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,12 @@ def echo_attributes(request,
client = Saml2Client(conf, state_cache=state,
identity_cache=IdentityCache(request.session))
subject_id = _get_subject_id(request.session)
identity = client.users.get_identity(subject_id,
check_not_on_or_after=False)
try:
identity = client.users.get_identity(subject_id,
check_not_on_or_after=False)
except AttributeError:
return HttpResponse("No active SAML identity found. Are you sure you have logged in via SAML?")

return render(request, template, {'attributes': identity[0]})


Expand Down

0 comments on commit d987dc0

Please sign in to comment.