Commit 02b2f3cb authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

fix some deprecation warnings and cleanup

parent d36697f86f99
......@@ -13,12 +13,14 @@ from datetime import datetime, timedelta
from yams import ValidationError
from logilab.mtconverter import xml_escape
from logilab.common.decorators import monkeypatch
from cubicweb.view import StartupView
from cubicweb.crypto import encrypt, decrypt
from cubicweb.web import (Redirect, controller, form, captcha,
formwidgets as wdg, formfields as ff)
from cubicweb.web.views import forms, urlrewrite, basetemplates
from cubicweb.server.repository import Repository
_ = unicode
......@@ -58,7 +60,7 @@ class ForgottenPasswordFormView(form.FormViewMixIn, StartupView):
def call(self):
form = self._cw.vreg['forms'].select('forgottenpassword', self._cw)
self.w(u'<p>%s</p>' % self._cw._(u'Forgot your password ?'))
class ForgottenPasswordSendMailController(controller.Controller):
__regid__ = 'forgottenpassword_sendmail'
......@@ -88,7 +90,7 @@ class ForgottenPasswordSendMailController(controller.Controller):
if field.required:
errors[] = self._cw._('required attribute')
data[] = value
captcha = self._cw.get_session_data('captcha', None, pop=True)
captcha ='captcha', None)
if captcha is None:
errors[None] = self._cw._('unable to check captcha, please try again')
elif data['captcha'].lower() != captcha.lower():
......@@ -136,7 +138,7 @@ class ForgottenPasswordRequestView(form.FormViewMixIn, StartupView):
form.add_hidden('use_email', key['use_email'])
form.add_hidden('revocation_id', key['revocation_id'])
self.w(u'<p>%s</p>' % self._cw._(u'Update your password:'))
class ForgottenPasswordRequestConfirm(controller.Controller):
......@@ -176,9 +178,6 @@ class PasswordResetView(StartupView):
# Monkey Patching
# ---------------
from cubicweb.server.repository import Repository
from logilab.common.decorators import monkeypatch
from cubicweb.mail import format_mail
def forgotpwd_send_email(self, data):
......@@ -211,8 +210,11 @@ def forgotpwd_send_email(self, data):
def forgotpwd_change_passwd(self, data):
session = self.internal_session()
rset = session.execute('Any F, U WHERE U is CWUser, U primary_email E, E address %(email)s, EXISTS(U has_fpasswd F, F revocation_id %(revid)s)',
{'email': data['use_email'], 'revid':data['revocation_id']})
rset = session.execute('Any F, U WHERE U is CWUser, U primary_email E, '
'E address %(email)s, EXISTS(U has_fpasswd F, '
'F revocation_id %(revid)s)',
{'email': data['use_email'],
'revid': data['revocation_id']})
if rset:
forgotpwd = rset.get_entity(0,0)
revocation_date = forgotpwd.revocation_date
......@@ -223,7 +225,7 @@ def forgotpwd_change_passwd(self, data):
session.execute('DELETE Fpasswd F WHERE F eid %(feid)s',
msg = session._(u'Your password has been changed !')
msg = session._(u'Your password has been changed.')
msg = session._(u'That link has either expired or is not valid.')
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