├── README.md ├── authapp ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── apps.cpython-38.pyc │ ├── forms.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── signals.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20201022_0503.py │ ├── 0003_auto_20201022_0505.py │ ├── 0004_remove_userregistrationmodel_date_of_birth.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-38.pyc │ │ ├── 0002_auto_20201022_0503.cpython-38.pyc │ │ ├── 0003_auto_20201022_0505.cpython-38.pyc │ │ ├── 0004_remove_userregistrationmodel_date_of_birth.cpython-38.pyc │ │ └── __init__.cpython-38.pyc ├── models.py ├── signals.py ├── templates │ ├── authapp │ │ ├── dashboard.html │ │ ├── edit.html │ │ ├── logged_out.html │ │ ├── password_change_done.html │ │ ├── password_change_form.html │ │ ├── password_reset_complete.html │ │ ├── password_reset_confirm.html │ │ ├── password_reset_done.html │ │ ├── password_reset_email.html │ │ ├── password_reset_form.html │ │ ├── register.html │ │ └── register_done.html │ ├── base.html │ ├── home.html │ ├── navbar.html │ ├── registration │ │ └── login.html │ └── static │ │ └── css │ │ └── style.css ├── tests.py ├── urls.py └── views.py ├── db.sqlite3 ├── images ├── chowacross_1.PNG └── chowacross_2.PNG ├── manage.py ├── requirements.txt ├── sent_emails ├── 20201022-134358-2387121828048.log ├── 20201022-134639-1956623136464.log └── 20201022-141421-2169355123872.log └── src ├── __init__.py ├── __pycache__ ├── __init__.cpython-38.pyc ├── settings.cpython-38.pyc ├── urls.cpython-38.pyc └── wsgi.cpython-38.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py /README.md: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |

32 | 33 | 34 | 35 | 36 |

User Authentication Web App

37 | 38 |

39 | This broject is aimed at solving the nuances involved in creating a user authentication end to end with django and also 40 | shows how to create user profiles using signals 41 |
42 | Explore the docs » 43 |
44 |
45 | View Demo 46 | · 47 | Report Bug 48 | · 49 | Request Feature 50 |

51 |

52 | 53 | 54 | 55 | 56 | ## Table of Contents 57 | 58 | * [About the Project](#about-the-project) 59 | * [Built With](#built-with) 60 | * [Getting Started](#getting-started) 61 | * [Prerequisites](#prerequisites) 62 | * [Installation](#installation) 63 | * [Usage](#usage) 64 | * [Roadmap](#roadmap) 65 | * [Contributing](#contributing) 66 | * [License](#license) 67 | * [Contact](#contact) 68 | * [Acknowledgements](#acknowledgements) 69 | 70 | 71 | 72 | 73 | ## About The Project 74 | 75 | ![GitHub Logo](/images/chowacross_1.PNG) 76 | 77 | ### Built With 78 | 79 | * python 3.8 80 | * django 3.0 81 | * django-bootstrap4 82 | * bootstrap4 83 | * fontawesome 84 | 85 | 86 | 87 | 88 | ## Getting Started 89 | 90 | To get a local copy up and running follow these simple steps. 91 | 92 | ### Prerequisites 93 | * pip 94 | ```sh 95 | download python 96 | ``` 97 | 98 | ### Installation 99 | 100 | 1. Clone the repo 101 | ```sh 102 | git clone https://github.com/cforcross/User-Authentication-Web-App.git 103 | ``` 104 | 2. Install requirements.txt 105 | ```sh 106 | pip install requirements.txt 107 | ``` 108 | 109 | ## Usage 110 | ###### Project Dashboard 111 | ![GitHub Logo](/images/chowacross_2.PNG) 112 | 113 | The above showcases the user dashboard after the given user has registerd and sign in, giving him/her the ability to Edit,and change passwords.And the sounds out.This takes 114 | then to the next page which gives them the ability to sign back into the application and if they can't remember their password,a password forgotten link is availalbe for 115 | them to then follow the steps inorde to reset their password 116 | 117 | _For more examples, please refer to the [Video demo](https://example.com)_ 118 | 119 | 120 | 121 | 122 | ## Roadmap 123 | 124 | See the [open issues](https://github.com/cforcross/User-Authentication-Web-App/issues) for a list of proposed features (and known issues). 125 | 126 | 127 | 128 | 129 | ## Contributing 130 | 131 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. 132 | 133 | 1. Fork the Project 134 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 135 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 136 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 137 | 5. Open a Pull Request 138 | 139 | 140 | 141 | 142 | ## License 143 | 144 | Distributed under the MIT License. See `LICENSE` for more information. 145 | 146 | 147 | 148 | 149 | ## Contact 150 | 151 | [@twitter_handle](https://twitter.com/chowacross) 152 | 153 | [github](https://github.com/cforcross/User-Authentication-Web-App.git) 154 | 155 | 156 | [linknd](https://www.linkedin.com/in/chowa-cross-4380a858/) 157 | 158 | 159 | [instagram](https://www.instagram.com/chowagroup/) 160 | 161 | 162 | 163 | 164 | ## Acknowledgements 165 | i'll begin by acknowledging the amazing guys at python,github and bootstrap,fontawesome the amazing work they do 166 | * [python](https://www.python.org/) 167 | * [Django](https://docs.djangoproject.com/en/3.1) 168 | * [fontawsome](https://fontawesome.com/) 169 | * [REadmetemplate](https://github.com/othneildrew/Best-README-Template) 170 | * [ Antonio Mele](https://www.packtpub.com/product/django-3-by-example-third-edition/9781838981952) 171 | 172 | 173 | 174 | 175 | [contributors-shield]: https://img.shields.io/github/contributors/cforcross/repo.svg?style=flat-square 176 | [contributors-url]: https://github.com/cforcross/repo/graphs/contributors 177 | [forks-shield]: https://img.shields.io/github/forks/cforcross/repo.svg?style=flat-square 178 | [forks-url]: https://github.com/cforcross/repo/network/members 179 | [stars-shield]: https://img.shields.io/github/stars/cforcross/repo.svg?style=flat-square 180 | [stars-url]: https://github.com/cforcross/repo/stargazers 181 | [issues-shield]: https://img.shields.io/github/issues/cforcross/repo.svg?style=flat-square 182 | [issues-url]: https://github.com/cforcross/repo/issues 183 | [license-shield]: https://img.shields.io/github/license/cforcross/repo.svg?style=flat-square 184 | [license-url]: https://github.com/cforcross/repo/blob/master/LICENSE.txt 185 | [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555 186 | [linkedin-url]: https://linkedin.com/in/cforcross 187 | [product-screenshot]: images/screenshot.png 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /authapp/__init__.py: -------------------------------------------------------------------------------- 1 | # loads the appconfig subclass 2 | default_app_config = 'authapp.apps.AuthappConfig' 3 | -------------------------------------------------------------------------------- /authapp/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/apps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/apps.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/forms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/forms.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/signals.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/signals.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /authapp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AuthappConfig(AppConfig): 5 | name = 'authapp' 6 | 7 | def ready(self): 8 | from . import signals 9 | -------------------------------------------------------------------------------- /authapp/forms.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.models import User 2 | from django import forms 3 | # from .models import Profile 4 | from django.contrib.auth.forms import AuthenticationForm, UsernameField 5 | from .models import UserRegistrationModel 6 | from django.contrib.auth.forms import PasswordResetForm 7 | 8 | 9 | class UserRegistration(forms.ModelForm): 10 | password = forms.CharField(label='Password', widget=forms.PasswordInput) 11 | password2 = forms.CharField( 12 | label='Repeat Password', widget=forms.PasswordInput) 13 | 14 | class Meta: 15 | model = User 16 | fields = ('username', 'first_name', 'last_name', 'email') 17 | 18 | def clean_password2(self): 19 | cd = self.cleaned_data 20 | if cd['password'] != cd['password2']: 21 | raise forms.ValidationError('Passwords don\'t match.') 22 | return cd['password2'] 23 | 24 | 25 | class UserEditForm(forms.ModelForm): 26 | class Meta: 27 | model = User 28 | fields = ('first_name', 'last_name', 'email') 29 | 30 | 31 | -------------------------------------------------------------------------------- /authapp/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.2 on 2020-10-22 02:01 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='UserRegistrationModel', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('date_of_birth', models.DateTimeField()), 22 | ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 23 | ], 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /authapp/migrations/0002_auto_20201022_0503.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.2 on 2020-10-22 02:03 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('authapp', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='userregistrationmodel', 15 | name='date_of_birth', 16 | field=models.DateTimeField(help_text='MM/DD/YYYY'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /authapp/migrations/0003_auto_20201022_0505.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.2 on 2020-10-22 02:05 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('authapp', '0002_auto_20201022_0503'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='userregistrationmodel', 15 | name='date_of_birth', 16 | field=models.DateTimeField(help_text='Please use the following format: YYYY-MM-DD.'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /authapp/migrations/0004_remove_userregistrationmodel_date_of_birth.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.2 on 2020-10-22 12:19 2 | 3 | from django.db import migrations 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('authapp', '0003_auto_20201022_0505'), 10 | ] 11 | 12 | operations = [ 13 | migrations.RemoveField( 14 | model_name='userregistrationmodel', 15 | name='date_of_birth', 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /authapp/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/migrations/__init__.py -------------------------------------------------------------------------------- /authapp/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/migrations/__pycache__/0002_auto_20201022_0503.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/migrations/__pycache__/0002_auto_20201022_0503.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/migrations/__pycache__/0003_auto_20201022_0505.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/migrations/__pycache__/0003_auto_20201022_0505.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/migrations/__pycache__/0004_remove_userregistrationmodel_date_of_birth.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/migrations/__pycache__/0004_remove_userregistrationmodel_date_of_birth.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /authapp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.conf import settings 3 | # Create your models here. 4 | 5 | 6 | class UserRegistrationModel(models.Model): 7 | user = models.OneToOneField( 8 | settings.AUTH_USER_MODEL, on_delete=models.CASCADE) 9 | 10 | -------------------------------------------------------------------------------- /authapp/signals.py: -------------------------------------------------------------------------------- 1 | from django.db.models.signals import post_save 2 | from django.contrib.auth.models import User 3 | from django.dispatch import receiver 4 | from .models import UserRegistrationModel 5 | 6 | 7 | @receiver(post_save, sender=User) 8 | def creater_profile(sender, instance, created, **kwargs): 9 | if created: 10 | profile = UserRegistrationModel.objects.create(user=instance) 11 | profile.save() 12 | -------------------------------------------------------------------------------- /authapp/templates/authapp/dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Dashboard{% endblock title %} 3 | {% block content %} 4 |

{{welcome}}

5 |
6 | Edit Your Profile or 7 | Change your password 8 |
9 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/authapp/edit.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load bootstrap4 %} 3 | {% block title %}Edit{% endblock title %} 4 | {% block content %} 5 |

Edit your account

6 |

You can edit your account using the follow form

7 |
8 | {% csrf_token %} 9 | {% bootstrap_form form %} 10 | {% buttons %} 11 | 12 | {% endbuttons %} 13 |
14 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/authapp/logged_out.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Logged out{% endblock %} 3 | {% block content %} 4 |

Logged out

5 |

6 | You have been successfully logged out. 7 |


8 | You can log-in again. 9 |

10 | {% endblock %} -------------------------------------------------------------------------------- /authapp/templates/authapp/password_change_done.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/authapp/templates/authapp/password_change_done.html -------------------------------------------------------------------------------- /authapp/templates/authapp/password_change_form.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load bootstrap4 %} 3 | {% block content %} 4 |

Change Your Password

5 |

Use the form below to change your Password

6 |
7 | {% csrf_token %} 8 | {% bootstrap_form form %} 9 | {% buttons %} 10 | 11 | {% endbuttons %} 12 |
13 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/authapp/password_reset_complete.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Password reset{% endblock %} 3 | {% block content %} 4 |

Password set

5 |

Your password has been set. You can 6 | log in now

7 | {% endblock %} -------------------------------------------------------------------------------- /authapp/templates/authapp/password_reset_confirm.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load bootstrap4 %} 3 | {% block title %}Reset your password{% endblock %} 4 | {% block content %} 5 |

Reset your password

6 | {% if validlink %} 7 |

Please enter your new password twice:

8 |
9 | {% csrf_token %} 10 | {% bootstrap_form form %} 11 | {% buttons %} 12 | 13 | {% endbuttons %} 14 |
15 | {% else %} 16 |

The password reset link was invalid, possibly because it has 17 | already been used. Please request a new password reset.

18 | {% endif %} 19 | {% endblock %} -------------------------------------------------------------------------------- /authapp/templates/authapp/password_reset_done.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Reset your password{% endblock %} 3 | {% block content %} 4 |

Reset your password

5 |

We've emailed you instructions for setting your password.

6 |

If you don't receive an email, please make sure you've entered 7 | the address you registered with.

8 | {% endblock %} -------------------------------------------------------------------------------- /authapp/templates/authapp/password_reset_email.html: -------------------------------------------------------------------------------- 1 | Someone asked for password reset for email {{email}}.Follow the Link below 2 | {{ protocol }}://{{ domain }}{% url "authapp:password_reset_confirm" 3 | uidb64=uid token=token %} -------------------------------------------------------------------------------- /authapp/templates/authapp/password_reset_form.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% load bootstrap4 %} 3 | {% block title %}Reset your password 4 | 5 | {% endblock title %} 6 | {% block content %} 7 |
8 |

Forgotten your Password

9 |

Enter your email address to obtain a new password

10 |
11 | {% csrf_token %} 12 | {% bootstrap_form form %} 13 | {% buttons %} 14 | 15 | {% endbuttons %} 16 |
17 |
18 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/authapp/register.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load bootstrap4 %} 3 | {% block title %}Registration 4 | 5 | {% endblock title %} 6 | {% block content %} 7 | 8 | {% if form.errors %} 9 | 10 | {% endif %} 11 | 12 |
13 | {% csrf_token %} 14 | {% bootstrap_form form %} 15 | {% buttons %} 16 | 17 | {% endbuttons %} 18 |
19 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/authapp/register_done.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 |

Welcome {{ new_user.first_name }}!

4 |

Your account has been successfully created. Now you can log in.

5 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | App {% block title %}{% endblock title %} 22 | 23 | 24 | 25 | {% include "navbar.html" %} 26 |
27 | {% block content %} 28 | 29 | {% endblock content %} 30 |
31 | 32 | 33 | 34 | 35 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /authapp/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Home{% endblock title %} 3 | {% block content %} 4 | 5 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/navbar.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /authapp/templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load bootstrap4 %} 3 | {% block title %}Login{% endblock title %} 4 | 5 | {% block content %} 6 |
7 |
8 |

Log-in

9 | {% if form.errors %} 10 |

11 | Your username and password didn't match.Please 12 | Please try again. 13 |

14 | {% else %} 15 |

Please, use the following form to log-in

16 | {% endif %} 17 |
18 | 19 |
20 |

Forgotten your password?

21 | {% csrf_token %} 22 | {% bootstrap_form form %} 23 | {% buttons %} 24 | 25 | 26 | {% endbuttons %} 27 |
28 |
29 | {% endblock content %} -------------------------------------------------------------------------------- /authapp/templates/static/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: lightgray; 3 | } 4 | 5 | .login__left { 6 | margin-left: 500px 7 | } -------------------------------------------------------------------------------- /authapp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /authapp/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .views import edit, dashboard, register 3 | from django.urls import reverse_lazy 4 | from django.contrib.auth.views import (LoginView, LogoutView, PasswordResetDoneView, PasswordResetView, 5 | PasswordResetCompleteView, PasswordResetConfirmView, 6 | PasswordChangeView, PasswordChangeDoneView, 7 | PasswordResetDoneView) 8 | 9 | app_name = 'authapp' 10 | 11 | urlpatterns = [ 12 | path('register/', register, name='register'), 13 | path('edit/', edit, name='edit'), 14 | path('dashboard/', dashboard, name='dashboard'), 15 | path('', LoginView.as_view(template_name='registration/login.html'), name='login'), 16 | path('logout/', LogoutView.as_view(template_name='authapp/logged_out.html'), name='logout'), 17 | path('password_change/', PasswordChangeView.as_view( 18 | template_name='authapp/password_change_form.html'), name='password_change'), 19 | path('password_change/dond/', PasswordChangeDoneView.as_view(template_name='authapp/password_change_done.html'), 20 | name='password_change_done'), 21 | path('password_reset/', PasswordResetView.as_view( 22 | template_name='authapp/password_reset_form.html', 23 | email_template_name='authapp/password_reset_email.html', 24 | success_url=reverse_lazy('authapp:password_reset_done')), name='password_reset'), 25 | path('password_reset/done/', PasswordResetDoneView.as_view( 26 | template_name='authapp/password_reset_done.html'), name='password_reset_done'), 27 | path('reset///', PasswordResetConfirmView.as_view( 28 | template_name='authapp/password_reset_confirm.html', 29 | success_url=reverse_lazy('authapp:login')), name='password_reset_confirm'), 30 | path('reset/done/', PasswordResetCompleteView.as_view( 31 | template_name='authapp/password_reset_complete.html'), name='password_reset_complete'), 32 | 33 | ] 34 | -------------------------------------------------------------------------------- /authapp/views.py: -------------------------------------------------------------------------------- 1 | from django.http import request 2 | from django.shortcuts import render 3 | from django.contrib.auth.decorators import login_required 4 | from .forms import UserRegistration, UserEditForm 5 | 6 | 7 | # Create your views here. 8 | 9 | @login_required 10 | def dashboard(request): 11 | context = { 12 | "welcome": "Welcome to your dashboard" 13 | } 14 | return render(request, 'authapp/dashboard.html', context=context) 15 | 16 | 17 | def register(request): 18 | if request.method == 'POST': 19 | form = UserRegistration(request.POST or None) 20 | if form.is_valid(): 21 | new_user = form.save(commit=False) 22 | new_user.set_password( 23 | form.cleaned_data.get('password') 24 | ) 25 | new_user.save() 26 | return render(request, 'authapp/register_done.html') 27 | else: 28 | form = UserRegistration() 29 | 30 | context = { 31 | "form": form 32 | } 33 | 34 | return render(request, 'authapp/register.html', context=context) 35 | 36 | 37 | @login_required 38 | def edit(request): 39 | if request.method == 'POST': 40 | user_form = UserEditForm(instance=request.user, 41 | data=request.POST) 42 | if user_form.is_valid(): 43 | user_form.save() 44 | else: 45 | user_form = UserEditForm(instance=request.user) 46 | context = { 47 | 'form': user_form, 48 | } 49 | return render(request, 'authapp/edit.html', context=context) 50 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/db.sqlite3 -------------------------------------------------------------------------------- /images/chowacross_1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/images/chowacross_1.PNG -------------------------------------------------------------------------------- /images/chowacross_2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/images/chowacross_2.PNG -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.0.9 2 | django-bootstrap4==2.2.0 3 | -------------------------------------------------------------------------------- /sent_emails/20201022-134358-2387121828048.log: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: Password reset on 127.0.0.1:8000 5 | From: webmaster@localhost 6 | To: cross@yahoo.com 7 | Date: Thu, 22 Oct 2020 10:43:58 -0000 8 | Message-ID: <160336343867.13084.17624992201475370147@DESKTOP-8LLQCDQ> 9 | 10 | Someone asked for password reset for email cross@yahoo.com.Follow the Link below 11 | http://127.0.0.1:8000{% url "authapp:password_reset_confirm" 12 | uidb64=uid token=token %} 13 | ------------------------------------------------------------------------------- 14 | -------------------------------------------------------------------------------- /sent_emails/20201022-134639-1956623136464.log: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: Password reset on 127.0.0.1:8000 5 | From: webmaster@localhost 6 | To: cross@yahoo.com 7 | Date: Thu, 22 Oct 2020 10:46:39 -0000 8 | Message-ID: <160336359946.9676.1818876989507815125@DESKTOP-8LLQCDQ> 9 | 10 | Someone asked for password reset for email cross@yahoo.com.Follow the Link below 11 | http://127.0.0.1:8000{% url "authapp:password_reset_confirm" 12 | uidb64=uid token=token %} 13 | ------------------------------------------------------------------------------- 14 | -------------------------------------------------------------------------------- /sent_emails/20201022-141421-2169355123872.log: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset="utf-8" 2 | MIME-Version: 1.0 3 | Content-Transfer-Encoding: 7bit 4 | Subject: Password reset on 127.0.0.1:8000 5 | From: webmaster@localhost 6 | To: cross@yahoo.com 7 | Date: Thu, 22 Oct 2020 11:14:21 -0000 8 | Message-ID: <160336526148.10924.4804684508268152008@DESKTOP-8LLQCDQ> 9 | 10 | Someone asked for password reset for email cross@yahoo.com.Follow the Link below 11 | http://127.0.0.1:8000{% url "authapp:password_reset_confirm" 12 | uidb64=uid token=token %} 13 | ------------------------------------------------------------------------------- 14 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/src/__init__.py -------------------------------------------------------------------------------- /src/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/src/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /src/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/src/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /src/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/src/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /src/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cforcross/User-Authentication-Web-App/8223c5f9ab3b711aefa379d134a91cbbb8fab8d6/src/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /src/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for src project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /src/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for src project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.1.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.1/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | import os 15 | 16 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 17 | BASE_DIR = Path(__file__).resolve().parent.parent 18 | TEMPLATE_DIR = os.path.join('templates', BASE_DIR) 19 | STATIC_DIR = os.path.join('static', BASE_DIR) 20 | 21 | # Quick-start development settings - unsuitable for production 22 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ 23 | 24 | # SECURITY WARNING: keep the secret key used in production secret! 25 | SECRET_KEY = 'pxz!5e7vki$4%fx2+xb-z6v_85b)0j)nwontigspp#!+fpxu*2' 26 | 27 | # SECURITY WARNING: don't run with debug turned on in production! 28 | DEBUG = True 29 | 30 | ALLOWED_HOSTS = [] 31 | 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'django.contrib.admin', 37 | 'django.contrib.auth', 38 | 'django.contrib.contenttypes', 39 | 'django.contrib.sessions', 40 | 'django.contrib.messages', 41 | 'django.contrib.staticfiles', 42 | 43 | 'authapp', 44 | 'bootstrap4' 45 | ] 46 | 47 | MIDDLEWARE = [ 48 | 'django.middleware.security.SecurityMiddleware', 49 | 'django.contrib.sessions.middleware.SessionMiddleware', 50 | 'django.middleware.common.CommonMiddleware', 51 | 'django.middleware.csrf.CsrfViewMiddleware', 52 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 53 | 'django.contrib.messages.middleware.MessageMiddleware', 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 55 | ] 56 | 57 | ROOT_URLCONF = 'src.urls' 58 | 59 | TEMPLATES = [ 60 | { 61 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 62 | 'DIRS': [TEMPLATE_DIR, ], 63 | 'APP_DIRS': True, 64 | 'OPTIONS': { 65 | 'context_processors': [ 66 | 'django.template.context_processors.debug', 67 | 'django.template.context_processors.request', 68 | 'django.contrib.auth.context_processors.auth', 69 | 'django.contrib.messages.context_processors.messages', 70 | ], 71 | }, 72 | }, 73 | ] 74 | 75 | WSGI_APPLICATION = 'src.wsgi.application' 76 | 77 | 78 | # Database 79 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 80 | 81 | DATABASES = { 82 | 'default': { 83 | 'ENGINE': 'django.db.backends.sqlite3', 84 | 'NAME': BASE_DIR / 'db.sqlite3', 85 | } 86 | } 87 | 88 | 89 | # Password validation 90 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators 91 | 92 | AUTH_PASSWORD_VALIDATORS = [ 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 101 | }, 102 | { 103 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 104 | }, 105 | ] 106 | 107 | 108 | # Internationalization 109 | # https://docs.djangoproject.com/en/3.1/topics/i18n/ 110 | 111 | LANGUAGE_CODE = 'en-us' 112 | 113 | TIME_ZONE = 'UTC' 114 | 115 | USE_I18N = True 116 | 117 | USE_L10N = True 118 | 119 | USE_TZ = True 120 | 121 | 122 | # Static files (CSS, JavaScript, Images) 123 | # https://docs.djangoproject.com/en/3.1/howto/static-files/ 124 | 125 | STATIC_URL = '/static/' 126 | STATICFILES_DIRS = [STATIC_DIR, ] 127 | 128 | 129 | LOGIN_REDIRECT_URL = 'authapp:dashboard' 130 | LOGIN_URL = 'login' 131 | LOGOUT_URL = 'logout' 132 | 133 | 134 | EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend" 135 | EMAIL_FILE_PATH = str(BASE_DIR.joinpath('sent_emails')) 136 | 137 | -------------------------------------------------------------------------------- /src/urls.py: -------------------------------------------------------------------------------- 1 | """src URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path('', include('authapp.urls', namespace='authapp')), 21 | path('admin/', admin.site.urls), 22 | ] 23 | -------------------------------------------------------------------------------- /src/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for src project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') 15 | 16 | application = get_wsgi_application() 17 | --------------------------------------------------------------------------------