From: Felix Dörre Date: Wed, 5 Nov 2014 08:47:17 +0000 (+0100) Subject: UPD: copy the login page from old software X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=4f532bd35f41121838756b67dfc0ca330940079e UPD: copy the login page from old software --- diff --git a/src/org/cacert/gigi/output/Form.java b/src/org/cacert/gigi/output/Form.java index 7cad69e7..b7caa214 100644 --- a/src/org/cacert/gigi/output/Form.java +++ b/src/org/cacert/gigi/output/Form.java @@ -34,7 +34,7 @@ public abstract class Form implements Outputable { @Override public void output(PrintWriter out, Language l, Map vars) { - out.println("
"); + out.println(""); failed = false; outputContent(out, l, vars); out.print("" + "" + "
"); + new LoginForm(req).output(resp.getWriter(), getLanguage(req), new HashMap()); } @Override @@ -39,7 +63,10 @@ public class LoginPage extends Page { tryAuthWithCertificate(req, cert[0]); } if (req.getMethod().equals("POST")) { - tryAuthWithUnpw(req); + try { + Form.getForm(req, LoginForm.class).submit(resp.getWriter(), req); + } catch (GigiApiException e) { + } } } diff --git a/src/org/cacert/gigi/pages/LoginPage.templ b/src/org/cacert/gigi/pages/LoginPage.templ new file mode 100644 index 00000000..c2418cda --- /dev/null +++ b/src/org/cacert/gigi/pages/LoginPage.templ @@ -0,0 +1,11 @@ +
+

+

+
+
+

+ - + - +
+

",!"",If you are having trouble with your username or password, please visit our %swiki page%s for more information?>

+
\ No newline at end of file diff --git a/static/static/default.css b/static/static/default.css index 70646809..294a99d4 100644 --- a/static/static/default.css +++ b/static/static/default.css @@ -800,4 +800,11 @@ pre{ pre.string{ display: inline; -} \ No newline at end of file +} + +.loginbox {background:#F5F7F7;border:2px solid #cccccc;margin:0px auto;height:auto;width:300px;padding:1em;text-align:center;} +.loginbox .smalltext {font-size:10px;} +.loginbox label {width:100px;display:block;float:left;} +.loginbox text {width:166px;display:block;float:left;} +.loginbox br {clear:left;} +.loginbox h1 {font-size:1.9em;text-align:center;} \ No newline at end of file diff --git a/tests/org/cacert/gigi/testUtils/ManagedTest.java b/tests/org/cacert/gigi/testUtils/ManagedTest.java index 6f6dfcf4..437031e4 100644 --- a/tests/org/cacert/gigi/testUtils/ManagedTest.java +++ b/tests/org/cacert/gigi/testUtils/ManagedTest.java @@ -331,12 +331,21 @@ public class ManagedTest extends ConfiguredTest { public static String login(String email, String pw) throws IOException { URL u = new URL("https://" + getServerName() + "/login"); HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + + String csrf = getCSRF(huc); + String headerField = stripCookie(huc.getHeaderField("Set-Cookie")); + + huc = (HttpURLConnection) u.openConnection(); + cookie(huc, headerField); huc.setDoOutput(true); OutputStream os = huc.getOutputStream(); - String data = "username=" + URLEncoder.encode(email, "UTF-8") + "&password=" + URLEncoder.encode(pw, "UTF-8"); + String data = "username=" + URLEncoder.encode(email, "UTF-8") + "&password=" + URLEncoder.encode(pw, "UTF-8") + "&csrf=" + URLEncoder.encode(csrf, "UTF-8"); os.write(data.getBytes()); os.flush(); - String headerField = huc.getHeaderField("Set-Cookie"); + headerField = huc.getHeaderField("Set-Cookie"); + if (headerField == null) { + return ""; + } return stripCookie(headerField); }