]> WPIA git - gigi.git/commitdiff
Merge "add: new function to set a challenge expired via test manager"
authorMarcus Mängel <m.maengel@inopiae.de>
Sun, 3 Nov 2019 06:25:47 +0000 (06:25 +0000)
committerGerrit Code Review <gigi-system@dogcraft.de>
Sun, 3 Nov 2019 06:25:47 +0000 (06:25 +0000)
build.xml
debian/control
src/club/wpia/gigi/dbObjects/User.java
src/club/wpia/gigi/pages/account/ChangeForm.java
src/club/wpia/gigi/pages/account/ChangePasswordForm.templ
src/club/wpia/gigi/pages/orga/AffiliationForm.java
src/club/wpia/gigi/pages/orga/AffiliationForm.templ
tests/club/wpia/gigi/pages/account/TestChangePassword.java

index abf1e3b1f9f2c434ab1fe755acc7ec940b0a278c..f03eca76c781f71abd573cbf1601af4f393197b1 100644 (file)
--- a/build.xml
+++ b/build.xml
        </target>
        <target name="update-effective-tlds">
                <mkdir dir="bin/club/wpia/gigi/util"/>
-               <exec executable="wget" dir="bin/club/wpia/gigi/util">
-                       <arg value="-N"/>
-                       <arg value="-q"/>
-                       <arg value="https://publicsuffix.org/list/effective_tld_names.dat"/>
-               </exec>
+               <copy file="/usr/share/publicsuffix/effective_tld_names.dat" tofile="bin/club/wpia/gigi/util/effective_tld_names.dat"/>
        </target>
 </project>
index fc5499d13aa64d801034b128a92d856ef1a43828..dae85c04837b00b587feeebd23d6557adb053ec4 100644 (file)
@@ -2,7 +2,7 @@ Source: wpia-gigi
 Section: java
 Priority: optional
 Maintainer: unknown <software@wpia.club>
-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
index e3beaf86cf65ba2bd6a38eb883996d48859a455b..4612d033f91d4d750700f77026913fc966417661 100644 (file)
@@ -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<String> nameParts = new TreeSet<>();
         for (int i = 0; i < names.length; i++) {
index de2a182d6bd7aa1348670f91321a3b412fb28750..590597b44653920c333f2859bf01f079ecbff930 100644 (file)
@@ -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<String, Object> 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);
index 4c350c560ce331c17bac58bdd4466b891309d5ea..8725dc3b0da702ffedf7b4580e4eb2081fd70f65 100644 (file)
@@ -5,10 +5,12 @@
   </tr>
   </thead>
   <tbody>
+  <? if($currentLoginMethod){ ?>
   <tr>
     <td><?=_Old Password?>: </td>
     <td><input class="form-control" type="password" name="oldpassword" required></td>
   </tr>
+  <? } ?>
   <tr>
     <td><?=_New Password?><span class="formMandatory">*</span>: </td>
     <td><input class="form-control" type="password" name="pword1" required></td>
index 1fd1c010ff09eb102f23263aba1a610500e06638..c99486277eaf6609d8abfc4969fddf21f19d7df2 100644 (file)
@@ -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;
index de3969b05c160b93f2616c2b560e5b47162e5b11..5d204b47b95dc2641e474267fac348bb47d98aa4 100644 (file)
@@ -10,7 +10,8 @@
     <td><?=$name?></td>
     <td><?=$e-mail?></td>
     <td><?=$master?></td>
-    <td><button class="btn btn-warning btn-confirm" data-confirm="<?=_Do you really want to delete the affiliation of ${name} (${e-mail}) to this organisation??>" data-reply="<?=_Cancel?>,<?=_Delete?>" type="submit" name="del" value="<?=$e-mail?>">X</button> </td>
+    <td><button class="btn btn-warning btn-confirm" data-confirm="<?=_Do you really want to delete the affiliation of ${nameString} (${e-mail}) to this organisation??>" data-reply="<?=_Cancel?>,<?=_Delete?>" type="submit" name="del" value="<?=$e-mail?>">X</button>
+    </td>
   </tr>
 <? } ?>
   <tr>
index e18ec02a5ea5be4f108d1423fda46e0a3bc23f99..73d23c56e8e3e99403da209b1d267446787e5c1e 100644 (file)
@@ -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;
+    }
 }