context_processors: adapt user_urls for authentic (#62335)
This commit is contained in:
parent
3e149997e4
commit
8d483aa45b
|
@ -214,4 +214,11 @@ def user_urls(request):
|
||||||
context['registration_url'] = (
|
context['registration_url'] = (
|
||||||
template_vars['idp_registration_url'] + '?' + urlencode({'next': absolute_uri})
|
template_vars['idp_registration_url'] + '?' + urlencode({'next': absolute_uri})
|
||||||
)
|
)
|
||||||
|
if 'authentic2' in settings.INSTALLED_APPS:
|
||||||
|
if request.path == '/login/':
|
||||||
|
context['login_url'] = '#'
|
||||||
|
context['registration_url'] = '/register/?' + request.GET.urlencode()
|
||||||
|
if request.path == '/register/':
|
||||||
|
context['login_url'] = '/login/?' + request.GET.urlencode()
|
||||||
|
context['registration_url'] = '#'
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -81,3 +81,22 @@ def test_user_urls(settings, rf):
|
||||||
'registration_url': 'https://idp/register/?next=http%3A%2F%2Ftestserver%2Fpage%2F',
|
'registration_url': 'https://idp/register/?next=http%3A%2F%2Ftestserver%2Fpage%2F',
|
||||||
'account_url': 'https://idp/accounts/?next=http%3A%2F%2Ftestserver%2Fpage%2F',
|
'account_url': 'https://idp/accounts/?next=http%3A%2F%2Ftestserver%2Fpage%2F',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from django.conf import settings as real_settings
|
||||||
|
|
||||||
|
real_settings.INSTALLED_APPS += ('authentic2',)
|
||||||
|
request = rf.get('/login/?next=coin&nonce=2')
|
||||||
|
assert user_urls(request) == {
|
||||||
|
'login_url': '#',
|
||||||
|
'logout_url': '/logout/?next=%2F',
|
||||||
|
'registration_url': '/register/?next=coin&nonce=2',
|
||||||
|
'account_url': 'https://idp/accounts/?next=http%3A%2F%2Ftestserver%2Flogin%2F%3Fnext%3Dcoin%26nonce%3D2',
|
||||||
|
}
|
||||||
|
|
||||||
|
request = rf.get('/register/?next=coin&nonce=2')
|
||||||
|
assert user_urls(request) == {
|
||||||
|
'login_url': '/login/?next=coin&nonce=2',
|
||||||
|
'logout_url': '/logout/?next=%2F',
|
||||||
|
'registration_url': '#',
|
||||||
|
'account_url': 'https://idp/accounts/?next=http%3A%2F%2Ftestserver%2Fregister%2F%3Fnext%3Dcoin%26nonce%3D2',
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue