Commit 9d11644d authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

[views] provide a pwdsent view to ease customization.

If IndexView is directly called after the pwdreset request is made, it's
not possible for an external cube to redefine the post-reset view without
overriding the forgotpasswordrequest controller.
parent 8621ddb0bb13
......@@ -66,8 +66,15 @@ class ForgottenPasswordSendMailController(controller.Controller):
def publish(self, rset=None):
data = self.checked_data()
msg = self.appli.repo.forgotpwd_send_email(data)
raise Redirect(self.build_url('', __message=msg))
try:
self.appli.repo.forgotpwd_send_email(data)
except ValidationError:
raise
except Exception, exc:
msg = str(exc)
else:
msg = self.req._(u'An email has been sent, follow instructions in there to change your password.')
raise Redirect(self.build_url('pwdsent', __message=msg))
def checked_data(self):
'''only basic data check here (required attributes and password
......@@ -91,6 +98,13 @@ class ForgottenPasswordSendMailController(controller.Controller):
raise ValidationError(None, errors)
return data
class PasswordSentView(StartupView):
id = 'pwdsent'
def call(self):
self.wview('index', self.rset)
# Second form, ask for a new password
# -----------------------------------
......@@ -100,7 +114,7 @@ class ForgottenPasswordRequestForm(forms.FieldsForm):
form_buttons = [wdg.SubmitButton()]
@property
def action(self):
return self.req.build_url(u'forgottenpasswordrequestconfirm')
return self.req.build_url(u'forgottenpassword-requestconfirm')
upassword = ff.StringField(widget=wdg.PasswordInput(), required=True)
......@@ -124,7 +138,7 @@ class ForgottenPasswordRequestView(form.FormViewMixIn, StartupView):
self.w(form.render())
class ForgottenPasswordRequestConfirm(controller.Controller):
id = 'forgottenpasswordrequestconfirm'
id = 'forgottenpassword-requestconfirm'
def publish(self, rset=None):
data = self.checked_data()
......@@ -222,5 +236,6 @@ def registration_callback(vreg):
class RegistrationSimpleReqRewriter(urlrewrite.SimpleReqRewriter):
rules = [
('/forgottenpassword', dict(vid='forgottenpassword')),
('/forgottenpasswordrequest', dict(vid='forgottenpasswordrequest'))
('/forgottenpasswordrequest', dict(vid='forgottenpasswordrequest')),
('/pwdsent', dict(vid='pwdsent')),
]
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