Handle IndieAuth redirect URIs that already have query parameters

This commit is contained in:
Danielle McLean 2017-11-03 12:14:15 +11:00
parent b658bf5c79
commit 6b1cd896ea
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -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))