fix: correctly end forms
authorFelix Dörre <felix@dogcraft.de>
Sat, 29 Jul 2017 21:12:08 +0000 (23:12 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 1 Aug 2017 18:35:04 +0000 (20:35 +0200)
Change-Id: Idc8e498c70cfc040730837242ddaa2384401dc58

src/club/wpia/gigi/output/template/Form.java

index ec3909e..1e94120 100644 (file)
@@ -136,17 +136,18 @@ public abstract class Form implements Outputable {
         try {
             SubmissionResult res = submit(req);
             req.setAttribute(SUBMIT_RESULT, res);
-            if (res instanceof RedirectResult) {
-                resp.sendRedirect(((RedirectResult) res).target);
-                return true;
-            }
             if (res.endsForm()) {
                 HttpSession hs = req.getSession();
                 hs.removeAttribute("form/" + getClass().getName() + "/" + csrf);
             }
+            if (res instanceof RedirectResult) {
+                resp.sendRedirect(((RedirectResult) res).target);
+                return true;
+            }
             return false;
         } catch (PermamentFormException e) {
             req.setAttribute(SUBMIT_RESULT, e);
+            req.getSession().removeAttribute("form/" + getClass().getName() + "/" + csrf);
             return false;
         } catch (GigiApiException e) {
             req.setAttribute(SUBMIT_RESULT, e);