Changes login redirect in authorize view.
This commit is contained in:
parent
61f6ae8e97
commit
e268c1c047
1 changed files with 10 additions and 9 deletions
|
@ -1,4 +1,6 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||||
|
from django.contrib.auth.views import redirect_to_login
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
|
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
@ -22,28 +24,27 @@ class AuthorizeView(View):
|
||||||
|
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
|
|
||||||
# This is for passing scopes into the form.
|
# This is for printing scopes in the form.
|
||||||
authorize.params.scope_str = ' '.join(authorize.params.scope)
|
authorize.params.scope_str = ' '.join(authorize.params.scope)
|
||||||
|
|
||||||
data = {
|
context = {
|
||||||
'params': authorize.params,
|
'params': authorize.params,
|
||||||
'client': authorize.client,
|
'client': authorize.client,
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(request, 'openid_provider/authorize.html', data)
|
return render(request, 'openid_provider/authorize.html', context)
|
||||||
else:
|
else:
|
||||||
next = urllib.quote(request.get_full_path())
|
path = request.get_full_path()
|
||||||
login_url = settings.LOGIN_URL + '?next=' + next
|
return redirect_to_login(
|
||||||
|
path, settings.LOGIN_URL, REDIRECT_FIELD_NAME)
|
||||||
return HttpResponseRedirect(login_url)
|
|
||||||
|
|
||||||
except (ClientIdError, RedirectUriError) as error:
|
except (ClientIdError, RedirectUriError) as error:
|
||||||
data = {
|
context = {
|
||||||
'error': error.error,
|
'error': error.error,
|
||||||
'description': error.description,
|
'description': error.description,
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(request, 'openid_provider/error.html', data)
|
return render(request, 'openid_provider/error.html', context)
|
||||||
|
|
||||||
except (AuthorizeError) as error:
|
except (AuthorizeError) as error:
|
||||||
uri = error.create_uri(
|
uri = error.create_uri(
|
||||||
|
|
Loading…
Reference in a new issue