Adding class to remember me
[django-cas-provider.git] / cas_provider / views.py
index 235b38f..ff7dcd7 100644 (file)
@@ -1,4 +1,5 @@
 import logging
+logger = logging.getLogger('cas_provider.views')
 import urllib
 
 from django.http import HttpResponse, HttpResponseRedirect
@@ -13,6 +14,8 @@ from models import ServiceTicket
 from utils import create_service_ticket
 from exceptions import SameEmailMismatchedPasswords
 
+from . import signals
+
 __all__ = ['login', 'validate', 'logout']
 
 
@@ -126,14 +129,22 @@ def socialauth_login(request, template_name='cas/login.html', success_redirect='
 def validate(request):
     service = request.GET.get('service', None)
     ticket_string = request.GET.get('ticket', None)
+    logger.debug("service: %s"% service)
+    logger.debug("ticket_string: %s"% ticket_string)
     if service is not None and ticket_string is not None:
         try:
             ticket = ServiceTicket.objects.get(ticket=ticket_string)
             username = ticket.user.username
             ticket.delete()
-            return HttpResponse("yes\n%s\n" % username)
-        except:
-            pass
+
+            results = signals.on_cas_collect_histories.send(sender=validate, for_email=ticket.user.email)
+            histories = '\n'.join('\n'.join(rs) for rc, rs in results)
+
+            return HttpResponse("yes\n%s\n%s" % (username, histories))
+
+        except Exception as e:
+            logger.exception("Got an exception!: %s"% e)
+
     return HttpResponse("no\n\n")