added authentication

This commit is contained in:
MassiveAtoms
2020-07-09 02:14:08 -03:00
parent 62b9dfd94f
commit cce3b1e733
18 changed files with 349 additions and 89 deletions

View File

@ -13,6 +13,20 @@
</head>
<body>
{% block topnav%}
<ul class="topnav">
{% if user.is_authenticated %}
<li class="active"><a href="{{user.get_absolute_url}}"> {{ user.get_username }}</a></li>
<li><a href="{% url 'logout'%}?next={{request.path}}">Logout</a></li>
{% else %}
<li><a href="{% url 'sign-up'%}?next={{request.path}}">Sign up</a></li>
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>
{% endif %}
</ul>
{% endblock %}
{% if user.is_authenticated %}
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
@ -138,6 +152,18 @@
}
}
</script>
{% else %}
<h1>You don't have permission to view this.</h1>
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>
or
<li><a href="{% url 'sign-up'%}?next={{request.path}}">Sign up</a></li>
{% endif %}
</body>
</html>

View File

@ -0,0 +1,6 @@
{% if user.is_authenticated %}
{% else %}
<h1>You don't have permission to view this.</h1>
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>
{% endif %}

View File

@ -0,0 +1,6 @@
{% extends "base.html" %}
{% block content %}
<h1> Welcome {{user}} </h1>
{% endblock %}

View File

@ -0,0 +1,7 @@
{% extends "stripped_base.html" %}
{% block content %}
<p>Logged out!</p>
<a href="{% url 'login'%}">Click here to login again.</a>
{% endblock %}

View File

@ -0,0 +1,39 @@
{% extends "stripped_base.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
{# Assumes you setup the password_reset view in your URLconf #}
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
{% endblock %}

View File

@ -0,0 +1,7 @@
{% extends "stripped_base.html" %}
{% block content %}
<h1>The password has been changed!</h1>
<p><a href="{% url 'login' %}">log in again?</a></p>
{% endblock %}

View File

@ -0,0 +1,28 @@
{% extends "stripped_base.html" %}
{% block content %}
{% if validlink %}
<p>Please enter (and confirm) your new password.</p>
<form action="" method="post">
{% csrf_token %}
<table>
<tr>
<td>{{ form.new_password1.errors }}
<label for="id_new_password1">New password:</label></td>
<td>{{ form.new_password1 }}</td>
</tr>
<tr>
<td>{{ form.new_password2.errors }}
<label for="id_new_password2">Confirm password:</label></td>
<td>{{ form.new_password2 }}</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Change my password" /></td>
</tr>
</table>
</form>
{% else %}
<h1>Password reset failed</h1>
<p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,4 @@
{% extends "stripped_base.html" %}
{% block content %}
<p>We've emailed you instructions for setting your password. If they haven't arrived in a few minutes, check your spam folder.</p>
{% endblock %}

View File

@ -0,0 +1,2 @@
Someone asked for password reset for email {{ email }}. Follow the link below:
{{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}

View File

@ -0,0 +1,11 @@
{% extends "stripped_base.html" %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{% if form.email.errors %}
{{ form.email.errors }}
{% endif %}
<p>{{ form.email }}</p>
<input type="submit" class="btn btn-default btn-lg" value="Reset password">
</form>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "stripped_base.html" %}
{% block content %}
<form method="post">
{% csrf_token %} {{form.as_p}} <input type="submit" value="Sign up"></form>
{% endblock %}

View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
{% block title %}<title>Local Library</title>{% endblock %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<!-- Add additional CSS in static file -->
{% load static %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>
<body>
{% block topnav%}
<ul class="topnav">
{% if user.is_authenticated %}
<li class="active"><a href="{{user.get_absolute_url}}"></a> {{ user.get_username }}</a></li>
<li><a href="{% url 'logout'%}?next={{request.path}}">Logout</a></li>
{% else %}
<li><a href="{% url 'sign-up'%}?next={{request.path}}">Sign up</a></li>
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>
{% endif %}
</ul>
{% endblock %}
<div class="container-fluid">
<div class="row">
<div class="col-sm-10 ">{% block content %}{% endblock %}</div>
</div>
</div>
</body>
</html>