mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
Redirect users to their original destination after verifying email.
Particularly useful for redirecting back to /promoted for selfserve advertisers.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
|
||||
%if thing.verify and not c.user.email_verified:
|
||||
<input type="hidden" name="verify" value="1"/>
|
||||
<input type="hidden" name="dest" value="${thing.dest}">
|
||||
<button type="submit" class="btn">${_('send verification email')}</button>
|
||||
%else:
|
||||
<button type="submit" class="btn">${_('save')}</button>
|
||||
|
||||
Reference in New Issue
Block a user