Mercurial > public > src > rhodecode
diff pylons_app/model/forms.py @ 518:a3d9d24acbec celery
Implemented password reset(forms/models/ tasks) and mailing tasks.
Added smtp mailer, configurations, cleaned user model
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 13 Sep 2010 01:27:41 +0200 |
parents | 00f883abdb0c |
children | 9dd38344c466 |
line wrap: on
line diff
--- a/pylons_app/model/forms.py Mon Sep 13 01:23:58 2010 +0200 +++ b/pylons_app/model/forms.py Mon Sep 13 01:27:41 2010 +0200 @@ -102,7 +102,7 @@ error_dict=self.e_dict) if user: if user.active: - if user.username == username and check_password(password, + if user.username == username and check_password(password, user.password): return value else: @@ -208,7 +208,20 @@ raise formencode.Invalid(msg, value, state, error_dict={'paths_root_path':msg}) - + +class ValidSystemEmail(formencode.validators.FancyValidator): + def to_python(self, value, state): + sa = meta.Session + try: + user = sa.query(User).filter(User.email == value).scalar() + if user is None: + raise formencode.Invalid(_("That e-mail address doesn't exist.") , + value, state) + finally: + meta.Session.remove() + + return value + #=============================================================================== # FORMS #=============================================================================== @@ -255,8 +268,14 @@ return _UserForm RegisterForm = UserForm - - + +def PasswordResetForm(): + class _PasswordResetForm(formencode.Schema): + allow_extra_fields = True + filter_extra_fields = True + email = All(ValidSystemEmail(), Email(not_empty=True)) + return _PasswordResetForm + def RepoForm(edit=False, old_data={}): class _RepoForm(formencode.Schema): allow_extra_fields = True