diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-04-08 21:14:23 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-04-08 21:14:23 +0200 |
commit | 46d306fa1c8fe1a6515969989a5e66fa8c9481b0 (patch) | |
tree | 2a85f6875b2d38b2166648678fe1f98e409420c9 | |
parent | Removed vagrant folder. (diff) | |
download | newspipe-46d306fa1c8fe1a6515969989a5e66fa8c9481b0.tar.gz newspipe-46d306fa1c8fe1a6515969989a5e66fa8c9481b0.tar.bz2 newspipe-46d306fa1c8fe1a6515969989a5e66fa8c9481b0.zip |
Authentication to JARR with email address or nickname.
-rw-r--r-- | src/web/forms.py | 15 | ||||
-rw-r--r-- | src/web/templates/login.html | 4 |
2 files changed, 12 insertions, 7 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') diff --git a/src/web/templates/login.html b/src/web/templates/login.html index 70e01f9c..4bbb28f9 100644 --- a/src/web/templates/login.html +++ b/src/web/templates/login.html @@ -7,9 +7,9 @@ {{ form.hidden_tag() }} <div class="form-group"> - {{ form.email(class_="form-control", placeholder=_('Your email')) }} + {{ form.email_or_nickmane(class_="form-control", placeholder=_('Your email or nickname')) }} </div> - {% for message in form.email.errors %} + {% for message in form.email_or_nickmane.errors %} <div class="alert alert-warning" role="alert">{{ message }}</div> {% endfor %} |