Skip to content

Commit b794265

Browse files
authored
Merge pull request Tivix#95 from chrsz/feature/demo_auth_drf
Add drf template auth customization
2 parents 89573f6 + bea6e3d commit b794265

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

demo/requirements.pip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
django>=1.9.0
2-
git+https://github.com/jazzband/dj-rest-auth.git@master
1+
django>=2.2
2+
dj-rest-auth @ git+https://github.com/jazzband/dj-rest-auth.git@master
33
djangorestframework>=3.11.0
44
djangorestframework-simplejwt==4.4.0
55
django-allauth>=0.24.1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{% extends "rest_framework/base.html" %}
2+
3+
{% block style %}
4+
{{ block.super }}
5+
<style>
6+
#btn-link {
7+
border: none;
8+
outline: none;
9+
background: none;
10+
display: block;
11+
padding: 3px 20px;
12+
clear: both;
13+
font-weight: 400;
14+
line-height: 1.42857143;
15+
color: #A30000;
16+
white-space: nowrap;
17+
width: 100%;
18+
text-align: left;
19+
}
20+
#btn-link:hover {
21+
background: #EEEEEE;
22+
color: #C20000;
23+
}
24+
</style>
25+
{% endblock %}
26+
27+
{% block userlinks %}
28+
{% if user.is_authenticated or response.data.access_token %}
29+
<li class="dropdown">
30+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
31+
{% firstof user.username 'Registered' %}
32+
<b class="caret"></b>
33+
</a>
34+
<ul class="dropdown-menu dropdown-menu-right">
35+
{% url 'rest_user_details' as user_url %}
36+
<li><a href="{{ user_url }}">User</a></li>
37+
<li>
38+
{% url 'rest_logout' as logout_url %}
39+
<form action="{{ logout_url }}" method="post">
40+
{% csrf_token %}
41+
<button type="submit" id="btn-link">Logout</button>
42+
</form>
43+
</li>
44+
</ul>
45+
</li>
46+
{% else %}
47+
{% url 'rest_login' as login_url %}
48+
<li><a href="{{ login_url }}">Login</a></li>
49+
{% url 'rest_register' as register_url %}
50+
<li><a href="{{ register_url }}">Register</a></li>
51+
{% endif %}
52+
{% endblock %}

0 commit comments

Comments
 (0)