aboutsummaryrefslogtreecommitdiff
path: root/src/web/forms.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-08 21:14:23 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-08 21:14:23 +0200
commit46d306fa1c8fe1a6515969989a5e66fa8c9481b0 (patch)
tree2a85f6875b2d38b2166648678fe1f98e409420c9 /src/web/forms.py
parentRemoved vagrant folder. (diff)
downloadnewspipe-46d306fa1c8fe1a6515969989a5e66fa8c9481b0.tar.gz
newspipe-46d306fa1c8fe1a6515969989a5e66fa8c9481b0.tar.bz2
newspipe-46d306fa1c8fe1a6515969989a5e66fa8c9481b0.zip
Authentication to JARR with email address or nickname.
Diffstat (limited to 'src/web/forms.py')
-rw-r--r--src/web/forms.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/web/forms.py b/src/web/forms.py
index 9aca234d..97ca75b0 100644
--- a/src/web/forms.py
+++ b/src/web/forms.py
@@ -89,8 +89,10 @@ class SigninForm(RedirectForm):
"""
Sign in form (connection to jarr).
"""
- email = EmailField("Email", [validators.Length(min=6, max=35),
- validators.Required(lazy_gettext("Please enter your email address."))])
+ email_or_nickmane = TextField("Email or nickname",
+ [validators.Length(min=3, max=35),
+ validators.Required(
+ lazy_gettext("Please enter your email address or nickname."))])
password = PasswordField(lazy_gettext('Password'),
[validators.Required(lazy_gettext("Please enter a password.")),
validators.Length(min=6, max=100)])
@@ -104,13 +106,16 @@ class SigninForm(RedirectForm):
validated = super().validate()
ucontr = UserController()
try:
- user = ucontr.get(email=self.email.data)
+ user = ucontr.get(**{'__or__':
+ {'email': self.email_or_nickmane.data,
+ 'nickname': self.email_or_nickmane.data}})
except NotFound:
- self.email.errors.append('Wrong login')
+ self.email_or_nickmane.errors.append(
+ 'Wrong email address or nickname')
validated = False
else:
if not user.is_active:
- self.email.errors.append('User is desactivated')
+ self.email_or_nickmane.errors.append('User is desactivated')
validated = False
if not ucontr.check_password(user, self.password.data):
self.password.errors.append('Wrong password')
bgstack15