Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DjangoBoilerplate/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
Expand Down Expand Up @@ -151,4 +151,5 @@
FRONTEND_URL = os.getenv('FRONTEND_URL')

LOGIN_REDIRECT_URL = '/v1/auth/profile/'
REGISTRATION_REDIRECT_URL = '/v1/auth/login'

3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE = DjangoBoilerplate.settings
python_files = tests.py test_*.py *_tests.py
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ python-dotenv==1.0.0
pytz==2023.3
sqlparse==0.4.4
typing_extensions==4.7.1
pytest==8.1.0
50 changes: 29 additions & 21 deletions templates/create_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
}

form {
max-width: 300px;
margin: 0 auto;
max-width: 300px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 1rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="email"],
input[type="submit"],
button[type="button"] {
width: 100%;
Expand All @@ -39,31 +42,36 @@
button[type="button"]:hover {
background-color: #45a049;
}

.error {
color: red;
font-size: 8px;
}
</style>
</head>
<body>
<h1>Create User</h1>
{% if error_message %}
<script>
alert("{{ error_message }}");
</script>
{% endif %}
{% if messages %}
<ul>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}


<form method="post">
{% csrf_token %}
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>

<label for="password">Password:</label>
<input type="password" id="password" name="password" required>

{% for field in form %}
<div class="form-group">
{{ field.label_tag }}
{{ field }}
{% if field.errors %}
{% for error in field.errors %}
<span class="error">{{ error }}</span>
{% endfor %}
{% endif %}
{% if field.help_text and not field.errors %}
<small class="form-text text-muted">{{ field.help_text }}</small>
{% endif %}
</div>
{% endfor %}


<input type="submit" value="Create User">
<button type="button" onclick="window.location.href='/v1/auth/login/'">Back to login</button>
Expand Down
44 changes: 38 additions & 6 deletions templates/auth/login.html → templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,56 @@
button[type="button"]:hover {
background-color: #45a049;
}
.error-message {
color: red;
font-size: 8px;
}
</style>
</head>
<body>
<h2>Login</h2>



{% if error_message %}
<script>

alert("{{ error_message }}");
</script>
{% endif %}
<form method="post">
{% csrf_token %}
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<input type="text" id="username" name="username" value="{{ form.username.value|default_if_none:'' }}" required>
{% if form.errors %}
{% for error in form.errors.username %}
<p class="error-message" >{{ error|striptags }}</p>
{% endfor %}
{% endif %}

<label for="password">Password:</label>
<input type="password" id="password" name="password" required>

<label for="password">Password:</label>
<input type="password" id="password" name="password" value="{{ form.password.value|default_if_none:'' }}" required>
{% if form.errors %}
{% for error in form.errors.password %}
<p class="error-message" >{{ error|striptags }}</p>
{% endfor %}
{% endif %}
{% if form.errors %}
{% for error in form.non_field_errors %}
<p class="error-message" >{{ error }}</p>
{% endfor %}
{% endif %}
<input type="submit" value="Login">
<button type="button" onclick="window.location.href='/v1/auth/forgot-password/'">Forgot Password?</button>
<button type="button" onclick="window.location.href='/v1/auth/reset_password/'">Forgot Password?</button>
<button type="button" onclick="window.location.href='/v1/auth/create/'">Signup</button>

</form>

{% if messages %}
{% for message in messages %}
{{ message }}
{% endfor %}
{% endif %}

</form>
</body>
</html>
41 changes: 41 additions & 0 deletions templates/registration/password_reset_complete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Password Reset Email Sent</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
}
h1 {
color: #45a049;
}
p {
margin-top: 20px;
}
a {
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Password Reset Completed</h1>
<p>Please login with new password.</p>
</div>
</body>
</html>
100 changes: 100 additions & 0 deletions templates/registration/password_reset_confirm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Password Reset Confirm</title>
<style>
/* Add your custom CSS styles here */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
background-color: #ffffff;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
width: 320px;
}

h1 {
margin-top: 0;
text-align: center;
}

form {
margin-top: 20px;
}

input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}

label {
display: block;
margin-bottom: 5px;
}

button[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: #ffffff;
border: none;
border-radius: 4px;
cursor: pointer;
}

button[type="submit"]:hover {
background-color: #45a049;
}

.error-message {
color: red;
font-size: 12px;
}
</style>
</head>
<body>
<div class="container">
<h1>Password Reset</h1>
<form method="post">
{% csrf_token %}
{% if form.new_password1.errors %}
<ul class="error-message">
{% for error in form.new_password1.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
<label for="id_new_password1">New Password:</label>
{{ form.new_password1 }}
<br>
<label for="id_new_password2">Confirm New Password:</label>
{{ form.new_password2 }}
<br>
{% if form.new_password2.errors %}
<ul class="error-message">
{% for error in form.new_password2.errors %}
{{ error }}
{% endfor %}
</ul>
{% endif %}

<button type="submit">Reset Password</button>
</form>
</div>
</body>
</html>
42 changes: 42 additions & 0 deletions templates/registration/password_reset_done.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Password Reset Email Sent</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
}
h1 {
color: #45a049;
}
p {
margin-top: 20px;
}
a {
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Password Reset Link Sent!</h1>
<p>A password reset link has been sent to your email address. Please check your inbox.</p>
<p>If you didn't receive the email, please check your spam folder.</p>
</div>
</body>
</html>
Loading