Commit 6fbdf534 authored by Charles Hebert's avatar Charles Hebert
Browse files

"Redirect" are removed from the server side

parent d10b2243aec1
......@@ -10,6 +10,7 @@ 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 cubicweb.web.views import forms, urlrewrite, basetemplates
from cubicweb.view import StartupView
......@@ -62,8 +63,8 @@ class ForgottenPasswordSendMailController(controller.Controller):
def publish(self, rset=None):
data = self.checked_data()
self.appli.repo.forgotpwd_send_email(data)
msg = self.appli.repo.forgotpwd_send_email(data)
raise Redirect(self.build_url('', __message=msg))
def checked_data(self):
'''only basic data check here (required attributes and password
......@@ -120,7 +121,8 @@ class ForgottenPasswordRequestConfirm(controller.Controller):
def publish(self, rset=None):
data = self.checked_data()
self.appli.repo.forgotpwd_change_passwd(data)
msg = self.appli.repo.forgotpwd_change_passwd(data)
raise Redirect(self.build_url('', __message=msg))
def checked_data(self):
fieldsform = self.vreg['forms'].select('forgottenpasswordrequest', self.req)
......@@ -147,6 +149,7 @@ from cubicweb.server.repository import Repository
from logilab.common.decorators import monkeypatch
from cubicweb.common.mail import format_mail
@monkeypatch(Repository)
def forgotpwd_send_email(self, data):
session = self.internal_session()
......@@ -167,10 +170,10 @@ def forgotpwd_send_email(self, data):
session.commit()
except:
msg = session._(u'You have already ask for a new password.')
raise Redirect(session.build_url('', __message=msg))
raise CubicWebException
else:
msg = session._(u'An error occured, this email is unknown.')
raise Redirect(session.build_url('', __message=msg))
raise CubicWebException
# send email
data['revocation_id'] = revocation_id
......@@ -192,7 +195,9 @@ def forgotpwd_send_email(self, data):
email = format_mail({}, [data['use_email']], content=content, subject=subject, config=session.vreg.config)
session.vreg.config.sendmails([(email, (data['use_email'],))])
msg = session._(u'An email has been sent, follow instructions in there to change your password.')
raise Redirect(session.build_url('', __message=msg))
return msg
except CubicWebException:
return msg
finally:
session.close()
......@@ -213,13 +218,11 @@ def forgotpwd_change_passwd(self, data):
{'feid':forgotpwd.eid})
session.commit()
msg = session._(u'Your password has been changed !')
raise Redirect(session.build_url('',__message=msg))
else:
msg = session._(u'That link has either expired or is not valid.')
raise Redirect(session.build_url('forgottenpassword', __message=msg))
else:
msg = session._(u'You already changed your password. This link has expired.')
raise Redirect(session.build_url('',__message=msg))
return msg
finally:
session.close()
......
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