From: Marcus Mängel Date: Sun, 3 Nov 2019 06:25:47 +0000 (+0000) Subject: Merge "add: new function to set a challenge expired via test manager" X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=ca4076d5c14224220bc0074ed56c0754bb8248b2;hp=0c07a64ca0c633fa1e4c867c4d5d12ef19ac23c2 Merge "add: new function to set a challenge expired via test manager" --- diff --git a/build.xml b/build.xml index abf1e3b1..f03eca76 100644 --- a/build.xml +++ b/build.xml @@ -355,10 +355,6 @@ - - - - - + diff --git a/debian/control b/debian/control index fc5499d1..dae85c04 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: wpia-gigi Section: java Priority: optional Maintainer: unknown -Build-Depends: debhelper (>= 8.0.0), dh-systemd, java7-sdk-headless, ant, wget +Build-Depends: debhelper (>= 8.0.0), dh-systemd, java7-sdk-headless, ant, wget, publicsuffix Standards-Version: 3.9.4 Homepage: https://wpia.club #Vcs-Git: git://git.debian.org/collab-maint/gigi.git diff --git a/src/club/wpia/gigi/dbObjects/User.java b/src/club/wpia/gigi/dbObjects/User.java index e3beaf86..4612d033 100644 --- a/src/club/wpia/gigi/dbObjects/User.java +++ b/src/club/wpia/gigi/dbObjects/User.java @@ -209,7 +209,7 @@ public class User extends CertificateOwner { setPassword(newPass); } - private void setPassword(String newPass) throws GigiApiException { + public void setPassword(String newPass) throws GigiApiException { Name[] names = getNames(); TreeSet nameParts = new TreeSet<>(); for (int i = 0; i < names.length; i++) { diff --git a/src/club/wpia/gigi/pages/account/ChangeForm.java b/src/club/wpia/gigi/pages/account/ChangeForm.java index de2a182d..590597b4 100644 --- a/src/club/wpia/gigi/pages/account/ChangeForm.java +++ b/src/club/wpia/gigi/pages/account/ChangeForm.java @@ -11,20 +11,28 @@ import club.wpia.gigi.localisation.Language; import club.wpia.gigi.output.template.Form; import club.wpia.gigi.output.template.Template; import club.wpia.gigi.output.template.TranslateCommand; +import club.wpia.gigi.pages.LoginPage; +import club.wpia.gigi.util.AuthorizationContext; public class ChangeForm extends Form { private User target; + private AuthorizationContext c; + public ChangeForm(HttpServletRequest hsr, User target) { super(hsr); this.target = target; + c = LoginPage.getAuthorizationContext(hsr); } private static final Template t = new Template(ChangePasswordPage.class.getResource("ChangePasswordForm.templ")); @Override public void outputContent(PrintWriter out, Language l, Map vars) { + if ( !c.isStronglyAuthenticated()) { + vars.put("currentLoginMethod", "pw"); + } t.output(out, l, vars); } @@ -34,14 +42,18 @@ public class ChangeForm extends Form { String p1 = req.getParameter("pword1"); String p2 = req.getParameter("pword2"); GigiApiException error = new GigiApiException(); - if (oldpassword == null || p1 == null || p2 == null) { + if ((oldpassword == null && !c.isStronglyAuthenticated()) || p1 == null || p2 == null) { throw new GigiApiException("All fields are required."); } if ( !p1.equals(p2)) { throw new GigiApiException("New passwords do not match."); } try { - target.changePassword(oldpassword, p1); + if (c.isStronglyAuthenticated()) { + target.setPassword(p1); + } else { + target.changePassword(oldpassword, p1); + } target.writeUserLog(target, "User triggered password reset"); } catch (GigiApiException e) { error.mergeInto(e); diff --git a/src/club/wpia/gigi/pages/account/ChangePasswordForm.templ b/src/club/wpia/gigi/pages/account/ChangePasswordForm.templ index 4c350c56..8725dc3b 100644 --- a/src/club/wpia/gigi/pages/account/ChangePasswordForm.templ +++ b/src/club/wpia/gigi/pages/account/ChangePasswordForm.templ @@ -5,10 +5,12 @@ + : + *: diff --git a/src/club/wpia/gigi/pages/orga/AffiliationForm.java b/src/club/wpia/gigi/pages/orga/AffiliationForm.java index 1fd1c010..c9948627 100644 --- a/src/club/wpia/gigi/pages/orga/AffiliationForm.java +++ b/src/club/wpia/gigi/pages/orga/AffiliationForm.java @@ -8,6 +8,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import club.wpia.gigi.GigiApiException; +import club.wpia.gigi.dbObjects.Name; import club.wpia.gigi.dbObjects.Organisation; import club.wpia.gigi.dbObjects.Organisation.Affiliation; import club.wpia.gigi.dbObjects.User; @@ -64,7 +65,9 @@ public class AffiliationForm extends Form { return false; } Affiliation aff = iter.next(); - vars.put("name", aff.getTarget().getPreferredName()); + Name n = aff.getTarget().getPreferredName(); + vars.put("name", n); + vars.put("nameString", n.toString()); vars.put("master", aff.isMaster() ? l.getTranslation("Master") : ""); vars.put("e-mail", aff.getTarget().getEmail()); return true; diff --git a/src/club/wpia/gigi/pages/orga/AffiliationForm.templ b/src/club/wpia/gigi/pages/orga/AffiliationForm.templ index de3969b0..5d204b47 100644 --- a/src/club/wpia/gigi/pages/orga/AffiliationForm.templ +++ b/src/club/wpia/gigi/pages/orga/AffiliationForm.templ @@ -10,7 +10,8 @@ - + + diff --git a/tests/club/wpia/gigi/pages/account/TestChangePassword.java b/tests/club/wpia/gigi/pages/account/TestChangePassword.java index e18ec02a..73d23c56 100644 --- a/tests/club/wpia/gigi/pages/account/TestChangePassword.java +++ b/tests/club/wpia/gigi/pages/account/TestChangePassword.java @@ -107,4 +107,19 @@ public class TestChangePassword extends ClientTest { } + @Test + public void testChangePasswordCertLogin() throws IOException, GigiApiException { + // no cert login + String np = URLEncoder.encode(TEST_PASSWORD + "v1", "UTF-8"); + String error = executeBasicWebInteraction(cookie, path, "pword1=" + np + "&pword2=" + np); + assertNotNull(error); + + // cert login + cookie = cookieWithCertificateLogin(u); + error = executeBasicWebInteraction(cookie, path, "pword1=" + np + "&pword2=" + np); + assertNull(error); + + cookie = login(u.getEmail(), TEST_PASSWORD); + loginCertificate = null; + } }