summaryrefslogtreecommitdiff
path: root/app/views/user.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-10-19 15:33:16 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-10-19 15:39:51 +0200
commitee596b2b55afa08f386ac4992ff3019250920ccf (patch)
tree342d9c0a11039bde64f22d128d36ac06c7b9913d /app/views/user.py
parentdf2f973109c47faee74d3b889c93bb211e865819 (diff)
downloadkosten-ee596b2b55afa08f386ac4992ff3019250920ccf.tar.gz
kosten-ee596b2b55afa08f386ac4992ff3019250920ccf.tar.bz2
kosten-ee596b2b55afa08f386ac4992ff3019250920ccf.zip
'Change password' support
Diffstat (limited to '')
-rw-r--r--app/views/user.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/app/views/user.py b/app/views/user.py
index e3c9251..a532c45 100644
--- a/app/views/user.py
+++ b/app/views/user.py
@@ -1,12 +1,12 @@
+# -*- encoding: utf-8 -*-
from . import Blueprint, flash, db, \
current_user, login_required, \
- templated, request, url_for
+ templated, redirect, request, url_for
-from ..forms import LoginForm
+from ..forms import LoginForm, ChangePwdForm
from ..login import login_user, logout_user, login_manager
-# we explicitly need flask's redirect and not our variant
-from flask import redirect
+import flask
mod = Blueprint('user', __name__)
@@ -17,13 +17,28 @@ def login():
if form.validate_on_submit():
login_user(form.user)
- return redirect(request.args.get('next') or url_for('index'))
+ # we explicitly need flask's variant as we redirect to a URI
+ return flask.redirect(request.args.get('next') or url_for('index'))
return { 'form': form }
+@mod.route('/cpw', methods=('GET', 'POST'))
+@login_required
+@templated
+def cpw():
+ form = ChangePwdForm()
+
+ if form.validate_on_submit():
+ current_user.set_password(form.newpwd)
+ db.session.commit()
+ flash(u"Passwort geändert.")
+ return redirect('index')
+
+ return { 'form': form }
+
@mod.route('/logout')
def logout():
logout_user()
- return redirect(url_for('.login'))
+ return redirect('.login')
login_manager.login_view = 'user.login'