misc: refactor login url build for OIDC providers (#38125)

This commit is contained in:
Serghei Mihai 2019-12-02 10:41:34 +01:00
parent e6d046710e
commit 7005cdc33d
2 changed files with 6 additions and 2 deletions

View File

@ -18,6 +18,7 @@ from django.utils.translation import gettext_noop
from django.shortcuts import render
from . import app_settings, utils
from authentic2.utils import make_url
class OIDCAuthenticator(object):
@ -37,5 +38,8 @@ class OIDCAuthenticator(object):
def login(self, request, *args, **kwargs):
context = kwargs.get('context', {})
if kwargs.get('instance'):
context['provider'] = kwargs['instance']
instance = kwargs['instance']
context['provider'] = instance
context['login_url'] = make_url('oidc-login', kwargs={'pk': instance.id},
request=request, keep_params=True)
return render(request, 'authentic2_auth_oidc/login.html', context)

View File

@ -1,4 +1,4 @@
<p id="oidc-p-{% firstof provider.slug provider.name|slugify %}">
<a id="oidc-a-{% firstof provider.slug provider.name|slugify %}"
href="{% url "oidc-login" pk=provider.pk %}?{{ request.GET.urlencode }}">{{ provider.name }}</a>
href="{{ login_url }}">{{ provider.name }}</a>
</p>