]> git.mxchange.org Git - addressbook-war.git/commitdiff
Continued with updating personal data:
authorRoland Haeder <roland@mxchange.org>
Sat, 5 Mar 2016 15:34:15 +0000 (16:34 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 5 Mar 2016 15:38:19 +0000 (16:38 +0100)
- added user password validator (from jjobs-war)
- added missing message strings
- added check if all required fields are set
- added preparing user instance and sending it to the EJB
- doChangeFoo() all need to return a string for next target page (not added yet)
- updated jar(s)

lib/juser-core.jar
lib/juser-lib.jar
nbproject/faces-config.NavData
src/java/org/mxchange/addressbook/validators/password/UserPasswordValidator.java [new file with mode: 0644]
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/login/login_enter_current_password.tpl
web/login/login_change_personal_data.xhtml

index 40c22b79f6b40e7f73ff091d16431972e436bbce..dab758462c35b87a226d553d9ae55630dad262db 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 35588bb0d8abbf068242701f1cb361706e19cff3..035059115efb07232f8a6f59afc1ea2b3c2c3bb4 100644 (file)
Binary files a/lib/juser-lib.jar and b/lib/juser-lib.jar differ
index 077c7ff682c471190ee5091679017fab9fb7c01e..882010c12ed1245a88c1894d4cfce2f56f3057ac 100644 (file)
@@ -17,7 +17,6 @@
     </Scope>
     <Scope Scope="Project">
         <Node id="login/login_shared_addressbooks.xhtml" x="400" y="900" zoom="true"/>
-        <Node id="login/login_edit_address.xhtml" x="150" y="450" zoom="true"/>
         <Node id="login/login_change_password.xhtml" x="1650" y="150" zoom="true"/>
         <Node id="privacy.xhtml" x="150" y="300" zoom="true"/>
         <Node id="login/login_start_sharing_addressbook.xhtml" x="900" y="450" zoom="true"/>
         <Node id="user/resend_link.xhtml" x="400" y="750" zoom="true"/>
         <Node id="login/login_index.xhtml" x="900" y="600" zoom="true"/>
         <Node id="login/login_own_addressbooks.xhtml" x="150" y="150" zoom="true"/>
-        <Node id="terms.xhtml" x="900" y="150" zoom="true"/>
         <Node id="admin/admin_logout.xhtml" x="150" y="900" zoom="true"/>
+        <Node id="terms.xhtml" x="900" y="150" zoom="true"/>
         <Node id="user/user_list.xhtml" x="400" y="600" zoom="true"/>
         <Node id="bye.xhtml" x="650" y="750" zoom="true"/>
         <Node id="index.xhtml" x="650" y="450" zoom="true"/>
         <Node id="user/register_done.xhtml" x="1400" y="300" zoom="true"/>
         <Node id="login/login_change_personal_data.xhtml" x="150" y="600" zoom="true"/>
         <Node id="user/user_profile.xhtml" x="400" y="150" zoom="true"/>
+        <Node id="imprint.xhtml" x="1150" y="150" zoom="true"/>
         <Node id="*" x="650" y="150" zoom="true"/>
         <Node id="user/show_addressbook.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="imprint.xhtml" x="1150" y="150" zoom="true"/>
         <Node id="user/login_error.xhtml" x="1150" y="450" zoom="true"/>
         <Node id="login/login_other_addressbooks.xhtml" x="650" y="600" zoom="true"/>
         <Node id="user/show_addressbook_entries.xhtml" x="1650" y="300" zoom="true"/>
diff --git a/src/java/org/mxchange/addressbook/validators/password/UserPasswordValidator.java b/src/java/org/mxchange/addressbook/validators/password/UserPasswordValidator.java
new file mode 100644 (file)
index 0000000..fa5fce3
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2016 quix0r
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.validators.password;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.inject.Inject;
+import org.mxchange.addressbook.beans.login.UserLoginWebSessionController;
+import org.mxchange.jcoreee.validator.string.BaseStringValidator;
+import org.mxchange.jusercore.container.login.LoginContainer;
+import org.mxchange.jusercore.container.login.UserLoginContainer;
+import org.mxchange.jusercore.model.user.UserUtils;
+
+/**
+ * A validator for validating passwords (if they match with stored)
+ * <p>
+ * @author Roland Haeder
+ */
+public class UserPasswordValidator extends BaseStringValidator implements Validator {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 48_581_795_687_317L;
+
+       /**
+        * User login controller
+        */
+       @Inject
+       private UserLoginWebSessionController loginController;
+
+       @Override
+       public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
+
+               // The required field
+               String[] requiredFileds = {"currentPassword"}; //NOI18N
+
+               // Pre-validation (example: not null, not a string, empty string ...)
+               super.preValidate(context, component, value, requiredFileds, false);
+
+               // value is known to be an entered password, so instance login container
+               LoginContainer container = new UserLoginContainer(this.loginController.getLoggedInUser(), (String) value);
+
+               // Test it here
+               if (!UserUtils.ifPasswordMatches(container, this.loginController.getLoggedInUser())) {
+                       // Password mismatches
+                       throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N
+               }
+
+               // Trace message
+               //this.getLogger().logTrace("validate: EXIT!"); //NOI18N
+       }
+}
index fa62ad347ee953a1206dbe8e26bf9d5a08ba6f6e..6978644225695dcb117079ff90a5fc2fd4214688 100644 (file)
@@ -285,3 +285,4 @@ LOGIN_ENTER_CURRENT_PASSWORD_CONFIRM=Derzeitiges Passwort:
 BUTTON_CHANGE_PERSONAL_DATA=Persoenliche Daten aendern
 #TODO: Please fix German umlaut!
 LOGIN_CHANGE_PERSONAL_DATA_TITLE=Persoenliche Daten aendern:
+ERROR_CURRENT_PASSWORD_MISMATCHING=Ihr eingegebenes Passwort entspricht nicht dem aktuell gespeicherten Passwort.
index 59bc76f07909d46d373b96f2228feb90bce3a21d..da62220a0bb45a80f660775552f046a4d4c1b85d 100644 (file)
@@ -270,3 +270,4 @@ LOGIN_ENTER_CURRENT_PASSWORD_CONFIRMATION_LEGEND_TITLE=Please enter your current
 LOGIN_ENTER_CURRENT_PASSWORD_CONFIRM=Current password:
 BUTTON_CHANGE_PERSONAL_DATA=Change personal data
 LOGIN_CHANGE_PERSONAL_DATA_TITLE=Change personal data:
+ERROR_CURRENT_PASSWORD_MISMATCHING=Your entered password doesn't match the currently stored one.
index 9bb8d1f8d53117552b59ac6a35902ac0d4b2ae9e..d5b622942223743f9a03da2833fbbb431d73972a 100644 (file)
                <validator-id>UserIdValidator</validator-id>
                <validator-class>org.mxchange.addressbook.validator.user.UserIdValidator</validator-class>
        </validator>
+       <validator>
+               <validator-id>UserPasswordValidator</validator-id>
+               <validator-class>org.mxchange.addressbook.validators.password.UserPasswordValidator</validator-class>
+       </validator>
        <navigation-rule>
                <from-view-id>*</from-view-id>
                <navigation-case>
index b218c729f9a72ffbd9258c7c8f44b84cb55ca539..26206e4c05a9c65940c7b9d8387745a394d9fb1f 100644 (file)
                                </div>
 
                                <div class="table_right">
-                                       <h:inputSecret class="input" id="currentPassword" size="10" maxlength="255" value="#{loginController.currentPassword}" required="true" />
+                                       <h:inputSecret class="input" id="currentPassword" size="10" maxlength="255" value="#{loginController.currentPassword}" required="true" validatorMessage="#{msg.ERROR_CURRENT_PASSWORD_MISMATCHING}">
+                                               <h:message for="currentPassword" class="errors" />
+                                               <f:validator for="currentPassword" validatorId="UserPasswordValidator" />
+                                       </h:inputSecret>
                                </div>
 
                                <div class="clear"></div>
index e1711f0defe630c57afbac614d1ef9ec3a215290..b441a30407cc969b4d63d7649322bd32a9a322b4 100644 (file)
@@ -29,7 +29,7 @@
 
                                                <div class="table_footer">
                                                        <h:commandButton class="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
-                                                       <h:commandButton class="submit" type="submit" id="change_personal_data" value="#{msg.BUTTON_CHANGE_PERSONAL_DATA}" action="#{userController.changePersonalData()}" />
+                                                       <h:commandButton class="submit" type="submit" id="change_personal_data" value="#{msg.BUTTON_CHANGE_PERSONAL_DATA}" action="#{userController.doChangePersonalData()}" />
                                                </div>
                                        </h:form>
                                </div>