views: force fc-register to always redirect post registration to fc-login-or-link (fixes #19270)
Without it linking to FC does not happen
This commit is contained in:
parent
73c774d1b2
commit
b9987366ca
|
@ -2,7 +2,8 @@ import uuid
|
|||
import requests
|
||||
import logging
|
||||
import json
|
||||
|
||||
import urlparse
|
||||
import urllib
|
||||
|
||||
from requests_oauthlib import OAuth2Session
|
||||
|
||||
|
@ -415,6 +416,14 @@ class RegistrationView(LoggerMixin, View):
|
|||
redirect_to = request.GET.get(REDIRECT_FIELD_NAME, '')
|
||||
if not is_safe_url(url=redirect_to, host=request.get_host()):
|
||||
redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)
|
||||
|
||||
# Prevent errors when redirect_to does not contain fc-login-or-link view
|
||||
parsed_redirect_to = urlparse.urlparse(redirect_to)
|
||||
if parsed_redirect_to.path != reverse('fc-login-or-link'):
|
||||
redirect_to = '%s?%s=%s' % (
|
||||
reverse('fc-login-or-link'),
|
||||
REDIRECT_FIELD_NAME,
|
||||
urllib.quote(redirect_to))
|
||||
if not 'email' in data:
|
||||
data[REDIRECT_FIELD_NAME] = redirect_to
|
||||
messages.info(request, _("FranceConnect didn't provide your email address, please do."))
|
||||
|
@ -422,10 +431,9 @@ class RegistrationView(LoggerMixin, View):
|
|||
signing.dumps(data)))
|
||||
data['valid_email'] = False
|
||||
data['franceconnect'] = True
|
||||
activation_url = \
|
||||
a2_utils.build_activation_url(request,
|
||||
next_url=redirect_to,
|
||||
**data)
|
||||
activation_url = a2_utils.build_activation_url(request,
|
||||
next_url=redirect_to,
|
||||
**data)
|
||||
return HttpResponseRedirect(activation_url)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue