summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2016-01-24 00:35:35 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2016-01-25 01:56:49 +0100
commitb3ea6ebd5d7ede77a7e500d7c043c47926e5a60e (patch)
tree6b1e8c93d492794ee23c925be21f55a4bed5dae9
parent33444268f3d37af033bd1731294168e54aba7b4c (diff)
downloadweb-b3ea6ebd5d7ede77a7e500d7c043c47926e5a60e.tar.gz
web-b3ea6ebd5d7ede77a7e500d7c043c47926e5a60e.tar.bz2
web-b3ea6ebd5d7ede77a7e500d7c043c47926e5a60e.zip
Use validate_on_submit helper
There is no need to validate the request.method by hand, the validate_on_submit helper does that.
-rw-r--r--accounts/__init__.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/accounts/__init__.py b/accounts/__init__.py
index e0b53b6..ae309ff 100644
--- a/accounts/__init__.py
+++ b/accounts/__init__.py
@@ -58,7 +58,7 @@ def template_default_context():
def index():
if not g.user:
form = LoginForm(request.form, csrf_enabled=False)
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
if login_user(form.username.data, form.password.data):
flash(u'Erfolgreich eingeloggt', 'success')
return redirect(url_for('settings'))
@@ -75,7 +75,7 @@ def index():
@logout_required
def register():
form = RegisterForm(request.form, csrf_enabled=False)
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
send_register_confirmation_mail(form.username.data, form.mail.data)
flash(u'Es wurde eine E-Mail an die angegebene Adresse geschickt, '
@@ -104,7 +104,7 @@ def register_complete(token):
return redirect(url_for('index'))
form = RegisterCompleteForm(request.form, csrf_enabled=False)
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
password = form.password.data
user = account.Account(username, mail, password=form.password.data)
@@ -138,7 +138,7 @@ def register_complete(token):
@logout_required
def lost_password():
form = LostPasswordForm(request.form, csrf_enabled=False)
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
#TODO: make the link only usable once (e.g include a hash of the old pw)
# atm the only thing we do is make the link valid for only little time
confirm_token = make_confirmation('lost_password', (form.user.uid,))
@@ -166,7 +166,7 @@ def lost_password_complete(token):
username, = http_verify_confirmation('lost_password', token.encode('ascii'), timeout=4*60*60)
form = RegisterCompleteForm(request.form, csrf_enabled=False)
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
user = app.user_backend.get_by_uid(username)
user.change_password(form.password.data)
app.user_backend.update(user, as_admin=True)
@@ -189,7 +189,7 @@ def lost_password_complete(token):
@login_required
def settings():
form = SettingsForm(request.form, mail=g.user.attributes['mail'])
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
changed = False
if request.form.get('submit_services'):