From 6b1cd896ea6c8f5d8ac730d30477c3ccca722e78 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Fri, 3 Nov 2017 12:14:15 +1100 Subject: [PATCH] Handle IndieAuth redirect URIs that already have query parameters --- lemonauth/views/indie.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lemonauth/views/indie.py b/lemonauth/views/indie.py index a66cf16..32d83ce 100644 --- a/lemonauth/views/indie.py +++ b/lemonauth/views/indie.py @@ -69,7 +69,7 @@ class IndieView(TemplateView): client = mf2py.Parser(url=params['client_id'], html_parser='html5lib') rels = (client.to_dict()['rel-urls'] - .get(params['redirect_uri'], {}) + .get(redirect_uri, {}) .get('rels', ())) verified = 'redirect_uri' in rels @@ -119,4 +119,7 @@ class IndieView(TemplateView): def approve(request): post = request.POST params = tokens.gen_auth_code(post) - return redirect(post['redirect_uri'] + '?' + urlencode(params)) + + uri = post['redirect_uri'] + sep = '&' if '?' in uri else '?' + return redirect(uri + sep + urlencode(params))