From 98942f76273ea7c2de58581efb5f915636611108 Mon Sep 17 00:00:00 2001 From: shyanukant rathi Date: Sat, 29 Jul 2023 21:46:21 +0530 Subject: [PATCH] update authentication --- account/views.py | 11 ++++++++--- squib/settings.py | 2 +- templates/account/auth.html | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/account/views.py b/account/views.py index f36e01d9..52fe3a9f 100644 --- a/account/views.py +++ b/account/views.py @@ -14,7 +14,9 @@ def login_view(request, *args, **kwargs): context = { 'form' : form, 'title' : "Login", - 'btn_label' : "Login" + 'btn_label' : "Login", + 'second_btn' : "register", + 'second_label' : "Don't have account" } return render(request, "account/auth.html", context) @@ -28,7 +30,8 @@ def logout_view(request, *args, **kwargs): 'form' : None, 'title':'Logout', 'description' : 'Are you sure , you want to logout?', - 'btn_label' : "Logout" + 'btn_label' : "Logout", + } return render(request, "account/auth.html", context) @@ -45,6 +48,8 @@ def register_view(request, *args, **kwargs): context = { 'form' : form, 'title':"Register", - 'btn_label' : "Register" + 'btn_label' : "Register", + 'second_btn' : "login", + 'second_label' : "Already a User" } return render(request, "account/auth.html", context) \ No newline at end of file diff --git a/squib/settings.py b/squib/settings.py index d03b71e9..a66ab9ba 100644 --- a/squib/settings.py +++ b/squib/settings.py @@ -33,7 +33,7 @@ # App name APP_NAME = 'squib' -ALLOWED_HOSTS = [".herokuapp.com"] +ALLOWED_HOSTS = [".herokuapp.com", '127.0.0.1'] # Tweet Custom Setting MAX_TWEET_LENGTH = 250 diff --git a/templates/account/auth.html b/templates/account/auth.html index 9cfeb54a..81218d46 100644 --- a/templates/account/auth.html +++ b/templates/account/auth.html @@ -5,14 +5,26 @@ {% block content %}

{{ title }}

- {% if description %} + {% if not request.user.is_authenticated %} +
+ {% csrf_token %} + {{form|crispy}} + +

+

+ + {{second_label}} {{ second_btn.capitalize }} + + + {% else %}

{{ description }}

- {% endif %}
{% csrf_token %} {{form|crispy}} +
+ {% endif %}
{% endblock %} \ No newline at end of file