Skip to content

Commit d987dc0

Browse files
committed
Show error message for echo_attributes when not logged in via SAML
This fixes issue #72
1 parent 5b5577c commit d987dc0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: djangosaml2/views.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,12 @@ def echo_attributes(request,
323323
client = Saml2Client(conf, state_cache=state,
324324
identity_cache=IdentityCache(request.session))
325325
subject_id = _get_subject_id(request.session)
326-
identity = client.users.get_identity(subject_id,
327-
check_not_on_or_after=False)
326+
try:
327+
identity = client.users.get_identity(subject_id,
328+
check_not_on_or_after=False)
329+
except AttributeError:
330+
return HttpResponse("No active SAML identity found. Are you sure you have logged in via SAML?")
331+
328332
return render(request, template, {'attributes': identity[0]})
329333

330334

0 commit comments

Comments
 (0)