diff --git a/amadeus/settings.py b/amadeus/settings.py index 1375de7..bea5236 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -180,7 +180,7 @@ LOGS_URL = 'logs/' # E-mail EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -DEFAULT_FROM_EMAIL = 'admin@admin.com' +DEFAULT_FROM_EMAIL = 'admin@amadeus.com.br' # Messages from django.contrib.messages import constants as messages_constants diff --git a/amadeus/templates/recover_pass_email_template.html b/amadeus/templates/recover_pass_email_template.html new file mode 100644 index 0000000..9b99948 --- /dev/null +++ b/amadeus/templates/recover_pass_email_template.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} + +{% load i18n %} + +{% block nav %} +{% endblock %} + +{% block breadcrumbs %} +{% endblock %} + +{% block sidebar %} +{% endblock sidebar %} + +{% autoescape off %} + +{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %} + +{% trans "Please go to the following page and choose a new password:" %} + +{% block reset_link %} + {{ domain }}{% url 'users:reset_password_confirm' uidb64=uid token=token %} + +{% endblock %} + +{% blocktrans %}The {{ site_name }} team{% endblocktrans %} + +{% endautoescape %} \ No newline at end of file diff --git a/users/forms.py b/users/forms.py index 8aa0c87..23b8658 100644 --- a/users/forms.py +++ b/users/forms.py @@ -3,12 +3,25 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from rolepermissions.shortcuts import assign_role from django.contrib.auth import update_session_auth_hash +from django.core.validators import validate_email +from django.core.exceptions import ValidationError from .models import User class Validation(forms.ModelForm): MIN_PASS_LENGTH = 8 MAX_UPLOAD_SIZE = 2*1024*1024 + def clean_email(self): + email = self.cleaned_data.get('email', '') + + try: + validate_email( email ) + return email + except ValidationError: + self._errors['email'] = [_('You must insert an email address')] + + return ValueError + def clean_image(self): image = self.cleaned_data.get('image', False) @@ -170,4 +183,18 @@ class ChangePassForm(Validation): } widgets = { 'password': forms.PasswordInput - } \ No newline at end of file + } + +class PassResetRequest(forms.Form): + email = forms.CharField(label = _('Email'), max_length = 254) + + def clean_email(self): + email = self.cleaned_data.get('email', '') + + try: + validate_email( email ) + return email + except ValidationError: + self._errors['email'] = [_('You must insert an email address')] + + return ValueError \ No newline at end of file diff --git a/users/templates/users/forgot_password.html b/users/templates/users/forgot_password.html new file mode 100644 index 0000000..6b1a9f6 --- /dev/null +++ b/users/templates/users/forgot_password.html @@ -0,0 +1,84 @@ +{% extends 'base.html' %} + +{% load static i18n %} +{% load widget_tweaks %} + +{% block nav %} +{% endblock %} + +{% block breadcrumbs %} +{% endblock %} + +{% block sidebar %} +{% endblock sidebar %} + +{% block content %} +
{% trans 'Enter your email below (the one used to access the platform) to recover your password' %}
+