diff options
Diffstat (limited to 'apioforum/auth.py')
-rw-r--r-- | apioforum/auth.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/apioforum/auth.py b/apioforum/auth.py index 49808ea..547f15e 100644 --- a/apioforum/auth.py +++ b/apioforum/auth.py @@ -8,6 +8,9 @@ import functools bp = Blueprint("auth", __name__, url_prefix="/auth") +def get_next(): + return request.args.get('next',url_for('index')) + @bp.route("/login",methods=('GET','POST')) def login(): if request.method == "POST": @@ -28,12 +31,14 @@ def login(): if err is None: session.clear() session['user'] = username - return redirect(url_for('auth.cool')) + flash("logged in successfully") + return redirect(get_next()) flash(err) return render_template("auth/login.html") + @bp.route("/register", methods=("GET","POST")) def register(): if request.method == "POST": @@ -58,7 +63,8 @@ def register(): db.commit() flash("successfully created account") session['user'] = username - return redirect(url_for("auth.cool")) + flash("registered successfully") + return redirect(get_next()) flash(err) @@ -67,7 +73,8 @@ def register(): @bp.route("/logout") def logout(): session.clear() - return redirect(url_for("auth.cool")) + flash("logged out successfully") + return redirect(get_next()) @bp.before_app_request def load_user(): |