diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 05c81b4e1..ffb7b51ff 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -955,9 +955,10 @@ class ApiController(RedditController, OAuth2ResourceController): VModhash(), email = ValidEmails("email", num = 1), password = VPassword(['newpass', 'verpass']), - verify = VBoolean("verify")) + verify = VBoolean("verify"), + dest=VDestination()) @api_doc(api_section.account) - def POST_update(self, form, jquery, email, password, verify): + def POST_update(self, form, jquery, email, password, verify, dest): """ Update account email address and password. @@ -986,7 +987,10 @@ class ApiController(RedditController, OAuth2ResourceController): updated = True if verify: # TODO: rate limit this? - emailer.verify_email(c.user) + if dest == '/': + dest = None + + emailer.verify_email(c.user, dest=dest) form.set_html('.status', _("you should be getting a verification email shortly.")) else: diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index ef545fe53..4cc9e9776 100755 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -1214,7 +1214,7 @@ class FormsController(RedditController): content = PaneStack( [InfoBar(message=infomsg), PrefUpdate(email=True, verify=True, - password=False)]) + password=False, dest=dest)]) return BoringPage(_("verify email"), content=content).render() @validate(VUser(), diff --git a/r2/r2/lib/emailer.py b/r2/r2/lib/emailer.py index 7eff9c764..bdcd63811 100644 --- a/r2/r2/lib/emailer.py +++ b/r2/r2/lib/emailer.py @@ -62,7 +62,7 @@ def _gold_email(body, to_address, from_name, kind): Email.handler.add_to_queue(None, to_address, from_name, g.goldthanks_email, kind, body = body) -def verify_email(user): +def verify_email(user, dest=None): """ For verifying an email address """ @@ -73,6 +73,8 @@ def verify_email(user): token = EmailVerificationToken._new(user) emaillink = 'http://' + g.domain + '/verification/' + token._id + if dest: + emaillink += '?dest=%s' % dest g.log.debug("Generated email verification link: " + emaillink) _system_email(user.email, diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index b2e873674..9a08f1bb5 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -864,10 +864,11 @@ class PrefOTP(Templated): class PrefUpdate(Templated): """Preference form for updating email address and passwords""" - def __init__(self, email = True, password = True, verify = False): + def __init__(self, email=True, password=True, verify=False, dest=None): self.email = email self.password = password self.verify = verify + self.dest = dest Templated.__init__(self) class PrefApps(Templated): diff --git a/r2/r2/templates/prefupdate.html b/r2/r2/templates/prefupdate.html index 797165a0d..c19af8448 100644 --- a/r2/r2/templates/prefupdate.html +++ b/r2/r2/templates/prefupdate.html @@ -93,6 +93,7 @@ %if thing.verify and not c.user.email_verified: + %else: