+
+def socialauth_login(request, user, template_name='cas/login.html', success_redirect='/account/'):
+ """ Similiar to login but user has been authenticated already through social auth.
+ This step authenticates the login and generates a service ticket.
+ """
+ service = request.session['service']
+ errors = []
+ if user is not None:
+ if user.is_active:
+ auth_login(request, user)
+ if service is not None:
+ ticket = create_service_ticket(user, service)
+ return HttpResponseRedirect(service + '?ticket=' + ticket.ticket)
+ else:
+ return HttpResponseRedirect(success_redirect)
+ else:
+ errors.append('This account is disabled.')
+ else:
+ errors.append('Incorrect username and/or password.')
+ return render_to_response(template_name, {'errors': errors}, context_instance=RequestContext(request))