mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-12-02 13:53:43 +03:00
Merge pull request #95 from chrsz/feature/demo_auth_drf
Add drf template auth customization
This commit is contained in:
commit
b79426533b
|
@ -1,5 +1,5 @@
|
|||
django>=1.9.0
|
||||
git+https://github.com/jazzband/dj-rest-auth.git@master
|
||||
django>=2.2
|
||||
dj-rest-auth @ git+https://github.com/jazzband/dj-rest-auth.git@master
|
||||
djangorestframework>=3.11.0
|
||||
djangorestframework-simplejwt==4.4.0
|
||||
django-allauth>=0.24.1
|
||||
|
|
52
demo/templates/rest_framework/api.html
Normal file
52
demo/templates/rest_framework/api.html
Normal file
|
@ -0,0 +1,52 @@
|
|||
{% extends "rest_framework/base.html" %}
|
||||
|
||||
{% block style %}
|
||||
{{ block.super }}
|
||||
<style>
|
||||
#btn-link {
|
||||
border: none;
|
||||
outline: none;
|
||||
background: none;
|
||||
display: block;
|
||||
padding: 3px 20px;
|
||||
clear: both;
|
||||
font-weight: 400;
|
||||
line-height: 1.42857143;
|
||||
color: #A30000;
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
#btn-link:hover {
|
||||
background: #EEEEEE;
|
||||
color: #C20000;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block userlinks %}
|
||||
{% if user.is_authenticated or response.data.access_token %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
{% firstof user.username 'Registered' %}
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
{% url 'rest_user_details' as user_url %}
|
||||
<li><a href="{{ user_url }}">User</a></li>
|
||||
<li>
|
||||
{% url 'rest_logout' as logout_url %}
|
||||
<form action="{{ logout_url }}" method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" id="btn-link">Logout</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
{% url 'rest_login' as login_url %}
|
||||
<li><a href="{{ login_url }}">Login</a></li>
|
||||
{% url 'rest_register' as register_url %}
|
||||
<li><a href="{{ register_url }}">Register</a></li>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user