Add some niiiice h-x-app rendering to the authorisation page, so you can get a pretty view of who's trying to auth
This commit is contained in:
parent
85be02c7d2
commit
5690e4bfab
3 changed files with 24 additions and 9 deletions
4
lemonauth/static/lemonauth/css/indie.styl
Normal file
4
lemonauth/static/lemonauth/css/indie.styl
Normal file
|
@ -0,0 +1,4 @@
|
|||
.h-x-app
|
||||
img
|
||||
height 2em
|
||||
margin-right .5em
|
|
@ -1,12 +1,18 @@
|
|||
{% extends 'lemoncurry/layout.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" type="text/stylus" href="{% static 'lemonauth/css/indie.styl' %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="container">
|
||||
<form class="card" method="post" action="{% url 'lemonauth:indie' %}">
|
||||
<h4 class="card-header">
|
||||
<h4 class="card-header h-x-app">
|
||||
{% if app %}<img class="u-logo p-name" src="{{ app.logo | first }}" alt="{{ app.name | first }}" />{% endif %}
|
||||
sign in to
|
||||
<a class="h-card code" href="{{ params.client_id }}">
|
||||
{{ params.client_id }}
|
||||
</a>
|
||||
{% if app %}{{ app.name | first }}{% endif %}
|
||||
{% if app %}({% endif %}<a class="u-url code{% if not app %} p-name{% endif %}" href="{{ params.client_id }}">{{ params.client_id }}</a>{% if app %}){% endif %}?
|
||||
</h4>
|
||||
|
||||
<div class="card-body">
|
||||
|
|
|
@ -15,9 +15,6 @@ class IndieView(TemplateView):
|
|||
required_params = ('me', 'client_id', 'redirect_uri')
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(IndieView, self).dispatch(*args, **kwargs)
|
||||
|
||||
def get(self, request):
|
||||
params = request.GET
|
||||
for param in self.required_params:
|
||||
|
@ -39,15 +36,23 @@ class IndieView(TemplateView):
|
|||
content_type='text/plain',
|
||||
)
|
||||
|
||||
client = mf2py.parse(url=params['client_id'])
|
||||
rels = client['rel-urls'].get(params['redirect_uri'], {}).get('rels', ())
|
||||
client = mf2py.Parser(url=params['client_id'], html_parser='html5lib')
|
||||
rels = (client.to_dict()['rel-urls']
|
||||
.get(params['redirect_uri'], {})
|
||||
.get('rels', ()))
|
||||
if 'redirect_uri' not in rels:
|
||||
return HttpResponseBadRequest(
|
||||
'your redirect_uri is not published on your client_id page',
|
||||
content_type='text/plain'
|
||||
)
|
||||
|
||||
try:
|
||||
app = client.to_dict(filter_by_type='h-x-app')[0]['properties']
|
||||
except IndexError:
|
||||
app = None
|
||||
|
||||
return render(request, self.template_name, {
|
||||
'app': app,
|
||||
'params': params,
|
||||
'title': 'indieauth',
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue