Return username in CAS1.0 on the second ligne

This commit is contained in:
Valentin Samir 2016-04-29 19:57:12 +02:00
parent 80b16c002b
commit b0e8d0ee05

View file

@ -563,7 +563,21 @@ class Validate(View):
ticket.service ticket.service
) )
) )
return HttpResponse("yes\n", content_type="text/plain") if (ticket.service_pattern.user_field and
ticket.user.attributs.get(ticket.service_pattern.user_field)):
username = ticket.user.attributs.get(
ticket.service_pattern.user_field
)
if isinstance(username, list):
try:
username = username[0]
except IndexError:
username = None
if not username:
username = ""
else:
username = ticket.user.username
return HttpResponse("yes\n%s\n" % username, content_type="text/plain")
except ServiceTicket.DoesNotExist: except ServiceTicket.DoesNotExist:
logger.warning( logger.warning(
( (