From 986a48c5e076e45f9e13ee34fb62cde8311bca5d Mon Sep 17 00:00:00 2001 From: kelvinhammond Date: Sat, 14 Dec 2013 13:01:41 -0600 Subject: [PATCH] Update forms.py Fixed: If login.next is not passed form throws error --- flask_security/forms.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/flask_security/forms.py b/flask_security/forms.py index e43ffd0..c540ff9 100644 --- a/flask_security/forms.py +++ b/flask_security/forms.py @@ -136,11 +136,12 @@ class NextFormMixin(): next = HiddenField() def validate_next(self, field): - url_next = urlparse.urlsplit(field.data) - url_base = urlparse.urlsplit(request.host_url) - if url_next.netloc and url_next.netloc != url_base.netloc: - field.data = '' - raise ValidationError(get_message('INVALID_REDIRECT')[0]) + if field.data: + url_next = urlparse.urlsplit(field.data) + url_base = urlparse.urlsplit(request.host_url) + if url_next.netloc and url_next.netloc != url_base.netloc: + field.data = '' + raise ValidationError(get_message('INVALID_REDIRECT')[0]) class RegisterFormMixin():