Commit 6f03d86c authored by Christophe de Vienne's avatar Christophe de Vienne
Browse files

Import ValidationError

Also, an old 'session' variable was still used.

Closes #4862475
parent 8c14c9391b55
......@@ -2,10 +2,13 @@ import random
import string
from datetime import datetime, timedelta
from cubicweb import ValidationError
from cubicweb.predicates import match_kwargs
from cubicweb.crypto import encrypt
from cubicweb.server import Service
_ = unicode
class ForgotPwdEmailService(Service):
"""Generate a password reset request, store it in the database, and send
reset email"""
......@@ -24,12 +27,12 @@ class ForgotPwdEmailService(Service):
existing_requests = cnx.execute('Any F WHERE U primary_email E, E address %(e)s, U has_fpasswd F',
{'e': use_email})
if existing_requests:
raise ValidationError(None, {None: cnx._('You have already asked for a new password.')})
raise ValidationError(None, {None: _('You have already asked for a new password.')})
rset = cnx.execute('INSERT Fpasswd X: X revocation_id %(a)s, X revocation_date %(b)s, '
'U has_fpasswd X WHERE U primary_email E, E address %(e)s',
{'a':revocation_id, 'b':revocation_date, 'e': use_email})
if not rset:
raise ValidationError(None, {None: session._(u'An error occured, this email address is unknown.')})
raise ValidationError(None, {None: _(u'An error occured, this email address is unknown.')})
class ForgotPwdChangePwdService(Service):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment