diff MoinMoin/apps/frontend/views.py @ 2933:08007ac96dda

Issue #483 and #482
author Aabhas Majumdar <majumdaraabhas@gmail.com>
date Mon, 23 Feb 2015 00:03:32 +0530
parents 7de85ecc3669
children e2b5a79a1e06
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Fri Feb 13 21:14:01 2015 +0100
+++ b/MoinMoin/apps/frontend/views.py	Mon Feb 23 00:03:32 2015 +0530
@@ -1577,6 +1577,10 @@
         return Response(flaskg._login_multistage, mimetype='text/html')
 
     if request.method in ['GET', 'HEAD']:
+        # we already have a logged-in user
+        if flaskg.user.valid:
+            flash(_("You are already logged in."), "info")
+            return redirect(url_for('.show_root'))
         form = LoginForm.from_defaults()
         for authmethod in app.cfg.auth:
             hint = authmethod.login_hint()
@@ -1586,7 +1590,8 @@
         form = LoginForm.from_flat(request.form)
         if form.validate():
             # we have a logged-in, valid user
-            return redirect(url_for('.show_root'))
+            next_url = request.args.get('next', default=url_for('.show_root'))
+            return redirect(next_url)
         # flash the error messages (if any)
         for msg in flaskg._login_messages:
             flash(msg, "error")
@@ -1601,7 +1606,8 @@
 def logout():
     flash(_("You are now logged out."), "info")
     flaskg.user.logout_session()
-    return redirect(url_for('.show_root'))
+    next_url = request.args.get('next', default=url_for('.show_root'))
+    return redirect(next_url)
 
 
 class ValidChangePass(Validator):