def cas(request): redirect_url = request.GET.get('redirect_url', 'http://www.my.jobs/') user = request.user if not user or user.is_anonymous(): guid = request.COOKIES.get('myguid') try: user = User.objects.get(user_guid=guid) except User.DoesNotExist: pass if not user or user.is_anonymous(): response = redirect("https://secure.my.jobs/?next=%s" % redirect_url) else: ticket = Ticket() try: ticket.ticket = uuid.uuid4() ticket.session_id = request.session.session_key ticket.user = request.user ticket.save() except IntegrityError: return cas(request) except Exception, e: logging.error("cas: %s" % e) response = redirect("https://secure.my.jobs/?next=%s" % redirect_url) else:
def cas(request): redirect_url = request.GET.get('redirect_url', 'http://www.my.jobs/') user = request.user if not user or user.is_anonymous(): guid = request.COOKIES.get('myguid') try: user = User.objects.get(user_guid=guid) except User.DoesNotExist: pass if not user or user.is_anonymous(): response = redirect("%s?ticket=%s&uid=%s" % (redirect_url, 'none', 'none')) else: ticket = Ticket() try: ticket.ticket = uuid.uuid4() ticket.session_id = request.session.session_key ticket.user = request.user ticket.save() except Exception: return cas(request) response = redirect("https://secure.my.jobs/?next=%s" % (redirect_url, ticket.ticket, ticket.user.user_guid)) caller = urlparse(redirect_url) try: page = CustomHomepage.objects.get(domain=caller.netloc.split(":")[0]) response.set_cookie(key='lastmicrosite', value="%s://%s" % (caller.scheme, caller.netloc), max_age=30 * 24 * 60 * 60, domain='.my.jobs') response.set_cookie(key='lastmicrositename', value=page.name, max_age=30 * 24 * 60 * 60, domain='.my.jobs') except CustomHomepage.DoesNotExist: pass return response
def cas(request): redirect_url = request.GET.get('redirect_url', 'http://www.my.jobs/') user = request.user if not user or user.is_anonymous(): guid = request.COOKIES.get('myguid') try: user = User.objects.get(user_guid=guid) except User.DoesNotExist: pass if not user or user.is_anonymous(): response = redirect("%s?ticket=%s&uid=%s" % (redirect_url, 'none', 'none')) else: ticket = Ticket() try: ticket.ticket = uuid.uuid4() ticket.session_id = request.session.session_key ticket.user = request.user ticket.save() except Exception: return cas(request) response = redirect( "https://secure.my.jobs/?next=%s" % (redirect_url, ticket.ticket, ticket.user.user_guid)) caller = urlparse(redirect_url) try: page = CustomHomepage.objects.get(domain=caller.netloc.split(":")[0]) response.set_cookie(key='lastmicrosite', value="%s://%s" % (caller.scheme, caller.netloc), max_age=30 * 24 * 60 * 60, domain='.my.jobs') response.set_cookie(key='lastmicrositename', value=page.name, max_age=30 * 24 * 60 * 60, domain='.my.jobs') except CustomHomepage.DoesNotExist: pass return response