mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
fix multiple auth backends
This commit is contained in:
parent
d08790a5b4
commit
3627c713fa
@ -11,7 +11,8 @@ from django.http import HttpResponse
|
||||
from django.views.generic import View
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.utils.encoding import smart_text
|
||||
from django.contrib import auth
|
||||
from awx.api.serializers import UserSerializer
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
|
||||
logger = logging.getLogger('awx.sso.views')
|
||||
|
||||
@ -39,8 +40,12 @@ class CompleteView(BaseRedirectView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
response = super(CompleteView, self).dispatch(request, *args, **kwargs)
|
||||
if self.request.user and self.request.user.is_authenticated():
|
||||
auth.login(self.request, self.request.user)
|
||||
logger.info(smart_text(u"User {} logged in".format(self.request.user.username)))
|
||||
response.set_cookie('userLoggedIn', 'true')
|
||||
current_user = UserSerializer(self.request.user)
|
||||
current_user = JSONRenderer().render(current_user.data)
|
||||
current_user = urllib.quote('%s' % current_user, '')
|
||||
response.set_cookie('current_user', current_user)
|
||||
return response
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user