Commit fa993e79 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

[views] safety belt: don't crash if expected keys are not found in data

i.e. : data.get('use_email').strip() won't work if use_email is not in
data
parent 7b7d3889d640
......@@ -10,11 +10,12 @@ import random
import string
from datetime import datetime, timedelta
from cubicweb._exceptions import CubicWebException
from cubicweb.web import (Redirect, controller, form, formwidgets as wdg, formfields as ff)
from yams import ValidationError
from cubicweb.web import (Redirect, controller, form, formwidgets as wdg,
formfields as ff)
from cubicweb.web.views import forms, urlrewrite, basetemplates
from cubicweb.view import StartupView
from cubicweb.common import ValidationError
from cubicweb.server.repository import Repository
from cubes.registration.views import CaptchaWidget, encrypt, decrypt
......@@ -29,8 +30,8 @@ class LogFormTemplateForgotPassword(basetemplates.LogFormTemplate):
def login_form(self, id):
super(LogFormTemplateForgotPassword, self).login_form(id)
self.req.add_css('cubes.forgotpwd.css')
self.w(u'<p style="text-align:center"><a href="%s">%s</a></p>' % (self.build_url('forgottenpassword'),
self.req._('Forgotten your password ?')))
self.w(u'<p style="text-align:center"><a href="%s">%s</a></p>' % (
self.build_url('forgottenpassword'), self.req._('Forgotten your password ?')))
# First form, send an email
# -------------------------
......@@ -134,8 +135,8 @@ class ForgottenPasswordRequestConfirm(controller.Controller):
if field.required:
errors[field.name] = self.req._('required attribute')
data[field.name] = value
data['use_email'] = self.req.form.get('use_email').strip()
data['revocation_id'] = self.req.form.get('revocation_id').strip()
data['use_email'] = self.req.form.get('use_email', '').strip()
data['revocation_id'] = self.req.form.get('revocation_id', '').strip()
if data['upassword'] != self.req.form.get('upassword-confirm'):
errors['upassword'] = _('passwords are different')
if errors:
......
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