log in log out

This commit is contained in:
Jędrzej Klepacki 2020-12-20 23:30:16 +01:00
parent bcf438dbc0
commit 468d6da4d6
7 changed files with 10 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -25,6 +25,11 @@
<li class="search_icon"><a href="#"><i class="icon-magnifier icons"></i></a></li>
<li class="user_icon"><a href="/homepage/my_offer"><i class="icon-user icons"></i></a></li>
<li ><a href="/homepage/add_offer"><img src="{% static "plus.png"%}" height="20"/></a></li>
{% if user.email %}
<li> <a href="logout_user"><img src="{% static "logout.png"%}" height="25"/></a></li>
{% else %}
<li> <a href="login"><img src="{% static "login.png"%}" height="25"/></a></li>
{% endif %}
</ul>
</nav>
</div>

View File

@ -17,6 +17,7 @@ urlpatterns = [
path('create_user', views.create_user, name='create_user'),
path('login', views.login, name='login'),
path('delete_user', views.delete_user, name='delete_user'),
path('logout_user', views.logout_user, name='logout_user'),
path('<int:user_id>/delete_user', views.delete_user, name='delete_user'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -231,8 +231,7 @@ def login(request):
return redirect(login)
return render(request , 'homepage/login.html')
def logout_user(request):
if request.method == 'POST':
auth.logout(request)
messages.success(request, 'Zostałeś wylogowany!')
return render(request, index)
def logout_user(request):
auth.logout(request)
messages.success(request, 'Zostałeś wylogowany!')
return redirect( index)