-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/update password reset template #261
Merged
KonstantinRaikhert
merged 24 commits into
develop
from
feature/update-password-reset-template
Sep 5, 2023
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
72334e0
Утилиты для работы с рассылкой email и регистрацией пользователей пер…
MikeWazowskyi 87b8ec2
Утилиты для работы с рассылкой email и регистрацией пользователей пер…
MikeWazowskyi f73f30e
Обновлены зависимости poetry.
MikeWazowskyi f71e3a0
Добавлен кастомный шаблон входа в админ-панель.
MikeWazowskyi cfdc8da
Добавлен кастомный шаблон письма с одноразовым кодом.
MikeWazowskyi ad9d938
Шаблоны разнесены по соответствующим директориям.
MikeWazowskyi 14bb9b4
Добавлены настройки для 2FA.
MikeWazowskyi 53d2aa1
Добавлено создание модели EmailDevice новых пользователей для рассылк…
MikeWazowskyi 493ce79
Добавлен кастомный сайт админ-панели с 2FA.
MikeWazowskyi 2dd442c
Заменен дефолтный сайт админ-панели на кастомизированный.
MikeWazowskyi 74ab09e
Добавлена форма для 2FA.
MikeWazowskyi 14cc3f3
Удалены ненужные модели.
MikeWazowskyi adacfe9
Обновлены пути к шаблонам.
MikeWazowskyi 0f29187
Утилиты для работы с рассылкой email и регистрацией пользователей пер…
MikeWazowskyi 25efb2b
Шаблоны перенесены в приложение users.
MikeWazowskyi 140ca49
Обновлены настройки для тестирования миграций.
MikeWazowskyi 15a8d41
Обновлен шаблон письма, добавлен восклицательный знак.
MikeWazowskyi 79580fe
Изменена основа шаблона на встроенный base_site.html.
MikeWazowskyi 27624fa
Изменен стиль отображения ошибок формы.
MikeWazowskyi 87aac47
Настройки админ-панели перенесены из urls в sites.
MikeWazowskyi 8419ff8
Ненужные шаблоны удалены.
MikeWazowskyi 3af8e46
Merge branch 'develop' into feature/update-password-reset-template
MikeWazowskyi 3fbdfda
Исправлены названия.
MikeWazowskyi 586043f
resolve conflicts
KonstantinRaikhert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
from django_otp.plugins.otp_email.models import EmailDevice | ||
|
||
from users.models import User | ||
from utils.emailing.reset_password import send_password_reset_email | ||
from users.utils.emailing.reset_password import send_password_reset_email | ||
|
||
|
||
@receiver(post_save, sender=User) | ||
def password_reset_email(sender, instance, created, **kwargs): | ||
"""Send email to new admin with link to set password.""" | ||
if created and not instance.is_superuser: | ||
send_password_reset_email(instance) | ||
if created: | ||
EmailDevice.objects.create( | ||
user=instance, | ||
email=instance.email, | ||
) | ||
if not instance.is_superuser: | ||
send_password_reset_email(instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django_otp.admin import OTPAdminSite | ||
|
||
from users.forms import CustomOTPAuthenticationForm | ||
|
||
|
||
class CustomOTPAdminSite(OTPAdminSite): | ||
"""Customized admin site.""" | ||
|
||
login_form = CustomOTPAuthenticationForm | ||
|
||
site_header = "Бот фонда 'Расправь крылья!'" | ||
site_title = "Бот фонда 'Расправь крылья!'" | ||
|
||
login_template = "authentication/login.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{% extends "admin/base_site.html" %} | ||
{% load i18n static %} | ||
|
||
{% block extrastyle %} | ||
{{ block.super }} | ||
<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" /> | ||
{{ form.media }} | ||
|
||
<style type="text/css"> | ||
input#id_otp_token, | ||
select#id_otp_device | ||
{ | ||
clear: both; | ||
padding: 6px; | ||
width: 100%; | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block bodyclass %}{{ block.super }} login{% endblock %} | ||
|
||
{% block usertools %}{% endblock %} | ||
|
||
{% block nav-global %}{% endblock %} | ||
|
||
{% block content_title %}{% endblock %} | ||
|
||
{% block breadcrumbs %}{% endblock %} | ||
|
||
{% block nav-sidebar %}{% endblock %} | ||
|
||
{% block content %} | ||
{% if form.errors and not form.non_field_errors %} | ||
<p class="errornote"> | ||
{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} | ||
</p> | ||
{% endif %} | ||
|
||
{% if form.non_field_errors %} | ||
{% for error in form.non_field_errors %} | ||
<p class="errornote"> | ||
{{ error }} | ||
</p> | ||
{% endfor %} | ||
{% endif %} | ||
|
||
<div id="content-main"> | ||
|
||
{% if user.is_authenticated %} | ||
<p class="errornote"> | ||
{% blocktrans trimmed %} | ||
You are authenticated as {{ username }}, but are not authorized to | ||
access this page. Would you like to login to a different account? | ||
{% endblocktrans %} | ||
</p> | ||
{% endif %} | ||
|
||
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %} | ||
<div class="form-row"> | ||
{{ form.username.errors }} | ||
{{ form.username.label_tag }} {{ form.username }} | ||
</div> | ||
<div class="form-row"> | ||
{{ form.password.errors }} | ||
{{ form.password.label_tag }} {{ form.password }} | ||
<input type="hidden" name="next" value="{{ next }}" /> | ||
</div> | ||
{% if form.get_user %} | ||
<div class="form-row"> | ||
{{ form.otp_token.errors }} | ||
<label for="id_otp_token" class="required">{% trans 'Одноразовый код:' %}</label> {{ form.otp_token }} | ||
</div> | ||
{% endif %} | ||
{% url 'admin_password_reset' as password_reset_url %} | ||
{% if password_reset_url %} | ||
<div class="password-reset-link"> | ||
<a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a> | ||
</div> | ||
{% endif %} | ||
<div class="submit-row"> | ||
<label> </label><input type="submit" value="{% trans 'Log in' %}" /> | ||
{% if form.get_user %} | ||
<label> </label><input type="submit" name="otp_challenge" value="{% trans 'Отправить код' %}" /> | ||
{% endif %} | ||
</div> | ||
</form> | ||
|
||
<script type="text/javascript"> | ||
document.getElementById('id_username').focus() | ||
</script> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь тоже можно восклицательный знак))