Skip to content

Commit

Permalink
update authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
shyanukant committed Jul 29, 2023
1 parent a4894ab commit 98942f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 8 additions & 3 deletions account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
2 changes: 1 addition & 1 deletion squib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions templates/account/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@
{% block content %}
<div class="col-10 mt-5 mx-auto">
<h1 class="fs-2"> {{ title }} </h1>
{% if description %}
{% if not request.user.is_authenticated %}
<form action="" method="post">
{% csrf_token %}
{{form|crispy}}
<button type="submit" class="btn btn-outline-success">{{ btn_label }}</button>
</form><br>
<hr><br>

<i><b>{{second_label}} </b></i><a class="btn btn-success" href="{% url second_btn %}"> {{ second_btn.capitalize }}
</a>

{% else %}
<p>{{ description }}</p>
{% endif %}
<form action="" method="post">
{% csrf_token %}
{{form|crispy}}
<button type="submit" class="btn btn-outline-success">{{ btn_label }}</button>
<button type="submit" class="btn btn-outline-danger" onclick="window.history.back()">Cancel</button>
</form>
{% endif %}
</div>

{% endblock %}

0 comments on commit 98942f7

Please sign in to comment.