Skip to content

Commit

Permalink
Enable ‘next’ redirection after registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
dokterbob committed Jul 3, 2014
1 parent 7b474ef commit 577a3a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions flask_security/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,12 @@ class ConfirmRegisterForm(Form, RegisterFormMixin,
pass


class RegisterForm(ConfirmRegisterForm, PasswordConfirmFormMixin):
pass
class RegisterForm(ConfirmRegisterForm, PasswordConfirmFormMixin,
NextFormMixin):
def __init__(self, *args, **kwargs):
super(RegisterForm, self).__init__(*args, **kwargs)
if not self.next.data:
self.next.data = request.args.get('next', '')


class ResetPasswordForm(Form, NewPasswordFormMixin, PasswordConfirmFormMixin):
Expand Down
4 changes: 2 additions & 2 deletions flask_security/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def get_post_login_redirect(declared=None):
return get_post_action_redirect('SECURITY_POST_LOGIN_VIEW', declared)


def get_post_register_redirect():
return get_post_action_redirect('SECURITY_POST_REGISTER_VIEW')
def get_post_register_redirect(declared=None):
return get_post_action_redirect('SECURITY_POST_REGISTER_VIEW', declared)


def find_redirect(key):
Expand Down
2 changes: 1 addition & 1 deletion flask_security/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def register():
login_user(user)

if not request.json:
return redirect(get_post_register_redirect())
return redirect(get_post_register_redirect(form.next.data))
return _render_json(form, include_auth_token=True)

if request.json:
Expand Down

0 comments on commit 577a3a8

Please sign in to comment.