X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Fmain%2FSignup.java;h=0b9abb73f3d6975bddc9e5e104cbcea7312f0486;hb=10ea8fe7c71bfab653785f6599103fdf36f8a842;hp=0cadcf64a8c4575b9d94831c59c0b95c43e5e69d;hpb=0a3573572ed9f1838d6c937b209f85111d2c4f5c;p=gigi.git diff --git a/src/org/cacert/gigi/pages/main/Signup.java b/src/org/cacert/gigi/pages/main/Signup.java index 0cadcf64..0b9abb73 100644 --- a/src/org/cacert/gigi/pages/main/Signup.java +++ b/src/org/cacert/gigi/pages/main/Signup.java @@ -9,7 +9,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.cacert.gigi.GigiApiException; -import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.database.GigiPreparedStatement; import org.cacert.gigi.database.GigiResultSet; import org.cacert.gigi.dbObjects.Name; @@ -20,6 +19,7 @@ import org.cacert.gigi.output.DateSelector; import org.cacert.gigi.output.template.Form; import org.cacert.gigi.output.template.Template; import org.cacert.gigi.pages.Page; +import org.cacert.gigi.util.CalendarUtil; import org.cacert.gigi.util.HTMLEncoder; import org.cacert.gigi.util.Notary; import org.cacert.gigi.util.PasswordStrengthChecker; @@ -56,6 +56,7 @@ public class Signup extends Form { vars.put("radius", radius ? " checked=\"checked\"" : ""); vars.put("helpOnNames", String.format(l.getTranslation("Help on Names %sin the wiki%s"), "", "")); vars.put("csrf", getCSRFToken()); + vars.put("dobmin", User.MINIMUM_AGE + ""); t.output(out, l, vars); } @@ -99,8 +100,13 @@ public class Signup extends Form { if ( !myDoB.isValid()) { outputError(out, req, "Invalid date of birth"); } - if ( !"1".equals(req.getParameter("cca_agree"))) { - outputError(out, req, "You have to agree to the SomeCA Community agreement."); + + if ( !CalendarUtil.isOfAge(myDoB.getDate(), User.MINIMUM_AGE)) { + outputError(out, req, "Entered dated of birth is below the restricted age requirements."); + } + + if ( !"1".equals(req.getParameter("tos_agree"))) { + outputError(out, req, "Acceptance of the ToS is required to continue."); } if (email.equals("")) { outputError(out, req, "Email Address was blank"); @@ -174,24 +180,17 @@ public class Signup extends Form { } private void run(HttpServletRequest req, String password) throws SQLException, GigiApiException { - try { - DatabaseConnection.getInstance().beginTransaction(); - User u = new User(email, password, buildupName, myDoB.getDate(), Page.getLanguage(req).getLocale()); - - try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `alerts` SET `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?")) { - ps.setInt(1, u.getId()); - ps.setBoolean(2, general); - ps.setBoolean(3, country); - ps.setBoolean(4, regional); - ps.setBoolean(5, radius); - ps.execute(); - } - Notary.writeUserAgreement(u, "CCA", "account creation", "", true, 0); + User u = new User(email, password, buildupName, myDoB.getDate(), Page.getLanguage(req).getLocale()); - DatabaseConnection.getInstance().commitTransaction(); - } finally { - DatabaseConnection.getInstance().quitTransaction(); + try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `alerts` SET `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?")) { + ps.setInt(1, u.getId()); + ps.setBoolean(2, general); + ps.setBoolean(3, country); + ps.setBoolean(4, regional); + ps.setBoolean(5, radius); + ps.execute(); } + Notary.writeUserAgreement(u, "ToS", "account creation", "", true, 0); } }