aboutsummaryrefslogtreecommitdiffstats
path: root/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'accounts')
-rw-r--r--accounts/views.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/accounts/views.py b/accounts/views.py
index 47b66a2..dc53660 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -1,4 +1,5 @@
import datetime
+from django import forms
from django.shortcuts import render
from django.urls import reverse
from django.conf import settings
@@ -43,12 +44,26 @@ MIDATA_ENABLED = settings.OAUTH_ENABLED
# override to remove help text
class RegisterForm(UserCreationForm):
+ email = forms.EmailField(required=True)
+
+ class Meta:
+ model = User
+ fields = ("username", "email", "password1", "password2")
+
def __init__(self, *args, **kwargs):
super(UserCreationForm, self).__init__(*args, **kwargs)
for fieldname in ['username', 'password1', 'password2']:
self.fields[fieldname].help_text = None
+ def save(self, commit=True):
+ user = super().save()
+ user.set_password(self.cleaned_data["password1"])
+ user.email = self.cleaned_data["email"]
+ if commit:
+ user.save()
+ return user
+
class AuthForm(AuthenticationForm):
error_messages = {
'invalid_login': ("Password errata e/o utente inesistente"),