Add next for login
This commit is contained in:
parent
6acd430529
commit
805a09b2e1
@ -30,14 +30,14 @@ register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def hopid_login_url(context, method=None):
|
||||
def hopid_login_url(context, *args, **kwargs):
|
||||
request = context['request']
|
||||
return get_hopid_login_url(request, method)
|
||||
return get_hopid_login_url(request, *args, **kwargs)
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def hopid_login_button(context, method=None):
|
||||
def hopid_login_button(context, *args, **kwargs):
|
||||
request = context['request']
|
||||
url = get_hopid_login_url(request, method)
|
||||
url = get_hopid_login_url(request, *args, **kwargs)
|
||||
|
||||
return render_to_string('django_hopid/hopid_login_button.html', {'url': url})
|
||||
|
@ -92,7 +92,7 @@ def generate_pkce_pair():
|
||||
return verifier, challenge
|
||||
|
||||
|
||||
def get_hopid_login_url(request, method=None):
|
||||
def get_hopid_login_url(request, method=None, next=None):
|
||||
nonce = secrets.token_urlsafe(32)
|
||||
verifier, challenge = generate_pkce_pair()
|
||||
|
||||
@ -101,11 +101,15 @@ def get_hopid_login_url(request, method=None):
|
||||
|
||||
base = f"{settings.HOPID_URL}/o/authorize/"
|
||||
|
||||
redirect_uri = settings.HOPID_CLIENT_CALLBACK_URI or settings.HOPID_CLIENT_URI + f'/id/callback/'
|
||||
if next:
|
||||
redirect_uri += f'?{urlencode({"next": next})}'
|
||||
|
||||
params = {
|
||||
"client_id": settings.HOPID_CLIENT_ID,
|
||||
"response_type": "code",
|
||||
"scope": "openid profile email",
|
||||
"redirect_uri": settings.HOPID_CLIENT_CALLBACK_URI or settings.HOPID_CLIENT_URI + '/id/callback/',
|
||||
"redirect_uri": redirect_uri,
|
||||
"nonce": nonce,
|
||||
"code_challenge": challenge,
|
||||
"code_challenge_method": "S256"
|
||||
|
Loading…
x
Reference in New Issue
Block a user