Skip to content

Commit

Permalink
Custom nav showing login state / linking to logout, closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 6, 2019
1 parent d0468cb commit 7ba2d74
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions datasette_auth_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,8 @@ def wrap_with_asgi_auth(app):
)

return wrap_with_asgi_auth


@hookimpl
def extra_template_vars(request):
return {"auth": request.scope.get("auth")}
20 changes: 20 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "default:base.html" %}

{% block extra_head %}
<style type="text/css">
.hd .logout {
float: right;
text-align: right;
padding-left: 1em;
}
</style>
{% endblock %}

{% block nav %}
{{ super() }}
{% if auth and auth.username %}
<p class="logout">
<strong>{{ auth.username }}</strong> &middot; <a href="/-/logout">Log out</a>
</p>
{% endif %}
{% endblock %}

0 comments on commit 7ba2d74

Please sign in to comment.