This is an automated email from the git hooks/post-receive script. New change to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git from 6955ed4 refs 6844 Remise en place de la fonctionnalité de demande de réinitialisation de mot de passe new 8d401db Ajout d'une méthode save sur AbstractWaoTopiaDao new 020efa1 Dans le jeu de données de test, on fait en sorte que chaque utilisateur fictif ait un mot de passe (le même pour tout le monde) new 5d86c42 Dans le bundle i18n, on écrit en casse normale, si on veut des majuscules à l'affichage, c'est un question de style, à faire en CSS new c256595 Pas la peine d'afficher deux boutons pour « Mot de passe oublié », pas la peine de l'afficher si la personne a réussi à s'authentifiée (étape de choix du profil ou acceptation CGU) new c23a182 Pas besoin de surcharger input() juste pour appeller super, on définit les @Result en haut de l'action (comme dans le reste de l'appli), aucune raison d'avoir à catcher une NoRoleAttributedException à ce moment new d53a19e Ajout d'un test pour vérifier le bon fonctionnement de la demande de renouvellement de mot de passe new 229ead8 Remaniement de askForPasswordReminder pour réutiliser du code au sein de WaoUsersService new 060144c Ajout d'une valeur i18n manquante new 0afd381 Suppression de code mort (?) The 9 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 0afd3815f924c096f60ee24e84241b8be91b2023 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:21:30 2015 +0200 Suppression de code mort (?) commit 060144c9eb31e4d10a411585863b57568db81a88 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:16:55 2015 +0200 Ajout d'une valeur i18n manquante commit 229ead8e0b9204d01f0cba30584cb612d74649ae Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:53 2015 +0200 Remaniement de askForPasswordReminder pour réutiliser du code au sein de WaoUsersService commit d53a19e3e60fe54d76d42bcab82aeb98e3ce3f35 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:28 2015 +0200 Ajout d'un test pour vérifier le bon fonctionnement de la demande de renouvellement de mot de passe commit c23a182ef0a557bd07cf207e98021b57323ae354 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:18 2015 +0200 Pas besoin de surcharger input() juste pour appeller super, on définit les @Result en haut de l'action (comme dans le reste de l'appli), aucune raison d'avoir à catcher une NoRoleAttributedException à ce moment commit c2565950475e8bb627b0b8cc45754a3fd98ebf7b Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:10:46 2015 +0200 Pas la peine d'afficher deux boutons pour « Mot de passe oublié », pas la peine de l'afficher si la personne a réussi à s'authentifiée (étape de choix du profil ou acceptation CGU) commit 5d86c42a1dad6309100db817b19aa8da49a723c0 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:08:41 2015 +0200 Dans le bundle i18n, on écrit en casse normale, si on veut des majuscules à l'affichage, c'est un question de style, à faire en CSS commit 020efa17d198339e52711d6dd41dd2ea2467b290 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:08:04 2015 +0200 Dans le jeu de données de test, on fait en sorte que chaque utilisateur fictif ait un mot de passe (le même pour tout le monde) commit 8d401db4c434c1142fefe31bd1e797536ded755e Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:06:50 2015 +0200 Ajout d'une méthode save sur AbstractWaoTopiaDao Summary of changes: .../java/fr/ifremer/wao/AbstractWaoTopiaDao.java | 14 ++- .../src/main/java/fr/ifremer/wao/WaoUtils.java | 5 + .../service/administration/WaoUsersService.java | 109 ++++++++++----------- .../wao/services/service/ObsMerFixtures.java | 4 + .../ifremer/wao/services/service/WaoFixtures.java | 9 ++ .../administration/WaoUsersServiceTest.java | 44 +++++++++ .../authentication/ForgottenPasswordAction.java | 20 ++-- .../main/resources/i18n/wao-web_en_GB.properties | 4 +- .../main/resources/i18n/wao-web_fr_FR.properties | 4 +- .../WEB-INF/content/authentication/login.jsp | 36 +++---- 10 files changed, 144 insertions(+), 105 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit 8d401db4c434c1142fefe31bd1e797536ded755e Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:06:50 2015 +0200 Ajout d'une méthode save sur AbstractWaoTopiaDao --- .../src/main/java/fr/ifremer/wao/AbstractWaoTopiaDao.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoTopiaDao.java index 67103d7..c587fad 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoTopiaDao.java @@ -31,11 +31,15 @@ public abstract class AbstractWaoTopiaDao<E extends TopiaEntity> extends Abstrac public void saveNullable(E entity) { if (entity != null) { - if (entity.isPersisted()) { - update(entity); - } else { - create(entity); - } + save(entity); + } + } + + public void save(E entity) { + if (entity.isPersisted()) { + update(entity); + } else { + create(entity); } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit 020efa17d198339e52711d6dd41dd2ea2467b290 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:08:04 2015 +0200 Dans le jeu de données de test, on fait en sorte que chaque utilisateur fictif ait un mot de passe (le même pour tout le monde) --- .../java/fr/ifremer/wao/services/service/ObsMerFixtures.java | 4 ++++ .../test/java/fr/ifremer/wao/services/service/WaoFixtures.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java index fa8a3bf..ed39904 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java @@ -48,6 +48,10 @@ public class ObsMerFixtures extends WaoFixtures { return newAuthenticatedWaoUser("jmichmuche", ObsProgram.OBSMER, UserRole.COORDINATOR, ifremer()); } + public AuthenticatedWaoUser robert() { + return newAuthenticatedWaoUser("robert@codelutin.com", ObsProgram.OBSMER, UserRole.COORDINATOR, ifremer()); + } + public void samplingPlan() { ifremer(); oceanet(); diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java index 1235c60..61bc1e3 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java @@ -23,6 +23,7 @@ package fr.ifremer.wao.services.service; import com.google.common.collect.Iterables; import fr.ifremer.wao.WaoTechnicalException; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyTopiaDao; import fr.ifremer.wao.entity.Laboratory; @@ -91,6 +92,7 @@ public class WaoFixtures { waoUser = new WaoUserImpl(); waoUser.setOrganisation(organisation); waoUser.setLogin(login); + waoUser.setPassword(WaoUtils.hashPassword(fakePassword())); waoUser.setFirstName("Prénom de " + login); waoUser.setLastName("Nom de " + login); waoUser.setActive(true); @@ -105,6 +107,13 @@ public class WaoFixtures { return new AuthenticatedWaoUser(waoUser, Iterables.getOnlyElement(waoUser.getUserProfile())); } + /** + * @return le mot de passe de tous les utilisateurs des fixtures + */ + public String fakePassword() { + return "fakePassword"; + } + public Company ifremer() { return getCompany("IFREMER", true); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit 5d86c42a1dad6309100db817b19aa8da49a723c0 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:08:41 2015 +0200 Dans le bundle i18n, on écrit en casse normale, si on veut des majuscules à l'affichage, c'est un question de style, à faire en CSS --- wao-web/src/main/resources/i18n/wao-web_en_GB.properties | 2 +- wao-web/src/main/resources/i18n/wao-web_fr_FR.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index 303aee2..53cd06c 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -378,7 +378,7 @@ wao.ui.form.authentication.error.inactiveWaoUser=This wao user is not active. Pl wao.ui.form.authentication.error.noRoleAttributed=This wao user has no role affected. Please, contact an administrator wao.ui.form.authentication.error.userMustAcceptCgu=You must accept the end-user agreement wao.ui.form.authentication.error.wrongCredentials=Incorrect credentials -wao.ui.form.authentication.forgottenPassword.recoverButton=RESET PASSWORD +wao.ui.form.authentication.forgottenPassword.recoverButton=Reset password wao.ui.form.authentication.forgottenPassword.title=Reset your WAO's password wao.ui.form.authentication.title=WAO authentication wao.ui.form.boardingFrom=Boardings since diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 68f026d..18434ae 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -379,7 +379,7 @@ wao.ui.form.authentication.error.inactiveWaoUser=Ce compte est inactif, veuillez wao.ui.form.authentication.error.noRoleAttributed=Aucun rôle n'est attribué à ce compte, veuillez contacter un responsable wao.ui.form.authentication.error.userMustAcceptCgu=Vous devez accepter les conditions générales d'utilisation wao.ui.form.authentication.error.wrongCredentials=Les informations d'authenfication ne sont pas correctes -wao.ui.form.authentication.forgottenPassword.recoverButton=RÉINITIALISER +wao.ui.form.authentication.forgottenPassword.recoverButton=Demander un nouveau mot de passe wao.ui.form.authentication.forgottenPassword.title=Récupération de votre mot de passe WAO wao.ui.form.authentication.title=Identification WAO wao.ui.form.boardingFrom=Sollicitations du navire depuis le -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit c2565950475e8bb627b0b8cc45754a3fd98ebf7b Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:10:46 2015 +0200 Pas la peine d'afficher deux boutons pour « Mot de passe oublié », pas la peine de l'afficher si la personne a réussi à s'authentifiée (étape de choix du profil ou acceptation CGU) --- .../WEB-INF/content/authentication/login.jsp | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp b/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp index 41382b4..3aeb73b 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp @@ -65,14 +65,6 @@ </s:else> - <s:if test="credentialsAsked"> - <s:url namespace="/authentication" action="forgotten-password" id="recoverPasswordURL"> - </s:url> - <s:a href="%{recoverPasswordURL}"> - <s:text name="wao.ui.forgotPassword"/> - </s:a> - </s:if> - <s:if test="userProfileAsked"> <s:radio name="userProfileId" list="userProfiles" label="%{getText('wao.ui.form.authentication.chooseUserProfile')}" /> @@ -88,21 +80,22 @@ </fieldset> <div class="form-actions"> - <s:if test="credentialsAsked"> - <s:submit type="button" cssClass="btn btn-primary"> - <s:param name="userPassordReminderAsked">true</s:param> - <s:text name="wao.ui.forgotPassword"/> - </s:submit> - </s:if> - <s:submit type="button" cssClass="btn btn-primary"> <s:text name="wao.ui.form.authentication.action.submit"/> </s:submit> - <s:url namespace="/authentication" action="login!input" id="cancelUrl"/> - <s:a href="%{cancelUrl}" cssClass="btn"> - <s:text name="wao.ui.action.cancel"/> - </s:a> + <s:if test="userProfileAsked || acceptCguAsked"> + <s:url namespace="/authentication" action="login!input" id="cancelUrl"/> + <s:a href="%{cancelUrl}" cssClass="btn"> + <s:text name="wao.ui.action.cancel"/> + </s:a> + </s:if> + <s:else> + <s:url namespace="/authentication" action="forgotten-password!input" id="recoverPasswordUrl" /> + <s:a href="%{recoverPasswordUrl}" cssClass="btn btn-link"> + <s:text name="wao.ui.forgotPassword"/> + </s:a> + </s:else> </div> </s:form> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit c23a182ef0a557bd07cf207e98021b57323ae354 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:18 2015 +0200 Pas besoin de surcharger input() juste pour appeller super, on définit les @Result en haut de l'action (comme dans le reste de l'appli), aucune raison d'avoir à catcher une NoRoleAttributedException à ce moment --- .../authentication/ForgottenPasswordAction.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/authentication/ForgottenPasswordAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/authentication/ForgottenPasswordAction.java index e3cb2ec..ce49700 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/authentication/ForgottenPasswordAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/authentication/ForgottenPasswordAction.java @@ -1,16 +1,18 @@ package fr.ifremer.wao.web.action.authentication; import fr.ifremer.wao.services.service.administration.InactiveWaoUserException; -import fr.ifremer.wao.services.service.administration.NoRoleAttributedException; import fr.ifremer.wao.services.service.administration.WaoUsersService; import fr.ifremer.wao.services.service.administration.WrongCredentialsException; import fr.ifremer.wao.web.WaoJspActionSupport; -import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; /** - * Created by davidcosse on 26/03/15. + * @since 5.1.2 */ +@Results({ + @Result(name="success", type="redirectAction", params = { "namespace", "/authentication", "actionName", "forgotten-password!input", "recovered", "%{recovered}", "login", "%{login}"}) +}) public class ForgottenPasswordAction extends WaoJspActionSupport { private static final long serialVersionUID = 1L; @@ -26,15 +28,8 @@ public class ForgottenPasswordAction extends WaoJspActionSupport { } @Override - @Action("forgotten-password-input") - public String input() throws Exception { - return super.input(); - } + public String execute() { - @Override - @Action(results = { - @Result(name="success", type="redirectAction", params = { "namespace", "/authentication", "actionName", "forgotten-password!input", "recovered", "%{recovered}", "login", "%{login}"})}) - public String execute() throws Exception { try { service.askForPasswordReminder(login); recovered = true; @@ -43,9 +38,6 @@ public class ForgottenPasswordAction extends WaoJspActionSupport { addFieldError("login", t("wao.ui.form.authentication.error.wrongCredentials")); return INPUT; } catch (InactiveWaoUserException inactiveWaoUserException) { - addFieldError("login", t("wao.ui.form.authentication.error.noRoleAttributed")); - return INPUT; - } catch (NoRoleAttributedException noRoleAttributedException) { addFieldError("login", t("wao.ui.form.authentication.error.inactiveWaoUser")); return INPUT; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit d53a19e3e60fe54d76d42bcab82aeb98e3ce3f35 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:28 2015 +0200 Ajout d'un test pour vérifier le bon fonctionnement de la demande de renouvellement de mot de passe --- .../administration/WaoUsersServiceTest.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java index e47d44d..6653feb 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java @@ -22,8 +22,10 @@ package fr.ifremer.wao.services.service.administration; */ import fr.ifremer.wao.services.AbstractWaoServiceTest; +import fr.ifremer.wao.services.service.ObsMerFixtures; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -33,11 +35,19 @@ public class WaoUsersServiceTest extends AbstractWaoServiceTest { protected WaoUsersService service; + protected ObsMerFixtures fixtures; + + protected boolean isDatabaseWithReferential() { + return true; + } + @Before public void setUp() { service = newService(WaoUsersService.class); + fixtures = new ObsMerFixtures(newServiceContext()); + } @Test @@ -50,4 +60,38 @@ public class WaoUsersServiceTest extends AbstractWaoServiceTest { } } + + @Test + public void testAskForNewPassword() throws WrongCredentialsException, NoRoleAttributedException, InactiveWaoUserException { + + String login = fixtures.robert().getWaoUser().getLogin(); + String fakePassword = fixtures.fakePassword(); + + service.authenticate(login, fakePassword); + + try { + service.askForPasswordReminder(login); + service.authenticate(login, "BJlNoN1Q"); + } catch (WrongCredentialsException | InactiveWaoUserException | NoRoleAttributedException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception", e); + } + Assert.fail("unexpected exception" + e); + } + + try { + service.authenticate(login, fakePassword); + Assert.fail("expected exception"); + } catch (WrongCredentialsException e) { + if (log.isDebugEnabled()) { + log.debug("expected exception", e); + } + } catch (NoRoleAttributedException | InactiveWaoUserException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception", e); + } + Assert.fail("unexpected exception" + e); + } + + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit 229ead8e0b9204d01f0cba30584cb612d74649ae Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:53 2015 +0200 Remaniement de askForPasswordReminder pour réutiliser du code au sein de WaoUsersService --- .../src/main/java/fr/ifremer/wao/WaoUtils.java | 5 + .../service/administration/WaoUsersService.java | 109 ++++++++++----------- 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java index 8f07aaf..0f4814e 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java @@ -29,6 +29,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.time.DateUtils; import org.nuiton.i18n.I18n; import org.nuiton.util.DateUtil; +import org.nuiton.util.StringUtil; import java.text.DateFormat; import java.text.ParseException; @@ -291,4 +292,8 @@ public class WaoUtils { } return keyWithHighestValue; } + + public static String hashPassword(String password) { + return StringUtil.encodeMD5(password); + } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/WaoUsersService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/WaoUsersService.java index 2e31b91..c9bea58 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/WaoUsersService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/WaoUsersService.java @@ -25,6 +25,7 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Boats; import fr.ifremer.wao.entity.ObsProgram; @@ -44,7 +45,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaEntities; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep; -import org.nuiton.util.StringUtil; import java.util.HashSet; import java.util.List; @@ -183,17 +183,13 @@ public class WaoUsersService extends WaoServiceSupport { } if (newPassword != null) { - String hashedNewPassword = StringUtil.encodeMD5(newPassword); + + String hashedNewPassword = WaoUtils.hashPassword(newPassword); waoUser.setPassword(hashedNewPassword); } if (updateWaoUserCommand.getPasswordStrategy().isGeneratePassword()) { - UserCredentialsEmail userCredentialsEmail = - getEmailService().newUserCredentialsEmail(); - userCredentialsEmail.addTo(waoUser); - userCredentialsEmail.setWaoUser(waoUser); - userCredentialsEmail.setNewPassword(newPassword); - getEmailService().send(userCredentialsEmail); + sendNewPasswordToUser(waoUser, newPassword); } if (waoUser.isUserProfileNotEmpty()) { @@ -204,19 +200,26 @@ public class WaoUsersService extends WaoServiceSupport { } } - WaoUserTopiaDao dao = getWaoUserDao(); - if (waoUser.isPersisted()) { - dao.update(waoUser); - } else { - dao.create(waoUser); - } + getWaoUserDao().save(waoUser); commit(); } + protected void sendNewPasswordToUser(WaoUser waoUser, String newPassword) { + + UserCredentialsEmail userCredentialsEmail = + getEmailService().newUserCredentialsEmail(); + userCredentialsEmail.addTo(waoUser); + userCredentialsEmail.setWaoUser(waoUser); + userCredentialsEmail.setNewPassword(newPassword); + + getEmailService().send(userCredentialsEmail); + + } + protected String newRandomPassword() { - return RandomStringUtils.random(8, true, true); + return RandomStringUtils.random(8, 0, 0, true, true, null, serviceContext.getRandom()); } @@ -249,21 +252,9 @@ public class WaoUsersService extends WaoServiceSupport { public WaoUser authenticate(String login, String clearPassword) throws WrongCredentialsException, NoRoleAttributedException, InactiveWaoUserException { - WaoUserTopiaDao dao = getWaoUserDao(); - - Optional<WaoUser> optionalWaoUser = dao.tryFindByEmailAndFetchCollections(login); - - WaoUser waoUser; - - if ( ! optionalWaoUser.isPresent()) { - if (log.isInfoEnabled()) { - log.info("no such user " + login); - } - throw new WrongCredentialsException(); - } + WaoUser waoUser = findWaoUserByLogin(login, true); - waoUser = optionalWaoUser.get(); - String hashedPassword = StringUtil.encodeMD5(clearPassword); + String hashedPassword = WaoUtils.hashPassword(clearPassword); if ( ! waoUser.getPassword().equals(hashedPassword)) { if (log.isWarnEnabled()) { @@ -272,10 +263,6 @@ public class WaoUsersService extends WaoServiceSupport { throw new WrongCredentialsException(); } - if ( ! waoUser.isActive()) { - throw new InactiveWaoUserException(waoUser); - } - if (waoUser.isUserProfileEmpty()) { throw new NoRoleAttributedException(waoUser); } @@ -284,28 +271,16 @@ public class WaoUsersService extends WaoServiceSupport { } - public void acceptCgu(WaoUser waoUser) { - - waoUser.setCguAccepted(serviceContext.getNow()); - - commit(); - - } - - protected UpdateWaoUserCommand getPasswordRecoveryUpdateWaoUserCommand(WaoUser waoUser) { - UpdateWaoUserCommand updateWaoUserCommand = new UpdateWaoUserCommand(); - updateWaoUserCommand.setWaoUser(waoUser); - updateWaoUserCommand.setPasswordStrategy(UpdateWaoUserCommandPasswordStrategy.GENERATE_NEW_PASSWORD); - updateWaoUserCommand.setPasswordStrategies(UpdateWaoUserCommandPasswordStrategy.getPasswordStrategiesForWaoUserCreation()); - return updateWaoUserCommand; - } + protected WaoUser findWaoUserByLogin(String login, boolean fetchDataForSession) throws WrongCredentialsException, InactiveWaoUserException { - public void askForPasswordReminder(String login) throws WrongCredentialsException, InactiveWaoUserException, NoRoleAttributedException { WaoUserTopiaDao dao = getWaoUserDao(); - Optional<WaoUser> optionalWaoUser = dao.tryFindByEmailAndFetchCollections(login); - - WaoUser waoUser; + Optional<WaoUser> optionalWaoUser; + if (fetchDataForSession) { + optionalWaoUser = dao.tryFindByEmailAndFetchCollections(login); + } else { + optionalWaoUser = dao.forLoginEquals(login).tryFindUnique(); + } if ( ! optionalWaoUser.isPresent()) { if (log.isInfoEnabled()) { @@ -314,18 +289,36 @@ public class WaoUsersService extends WaoServiceSupport { throw new WrongCredentialsException(); } - waoUser = optionalWaoUser.get(); + WaoUser waoUser = optionalWaoUser.get(); if ( ! waoUser.isActive()) { throw new InactiveWaoUserException(waoUser); } - if (waoUser.isUserProfileEmpty()) { - throw new NoRoleAttributedException(waoUser); - } + return waoUser; + } - UpdateWaoUserCommand updateWaoUserCommand = getPasswordRecoveryUpdateWaoUserCommand(waoUser); + public void acceptCgu(WaoUser waoUser) { + + waoUser.setCguAccepted(serviceContext.getNow()); + + commit(); + + } + + public void askForPasswordReminder(String login) throws WrongCredentialsException, InactiveWaoUserException { + + WaoUser waoUser = findWaoUserByLogin(login, false); + + String newPassword = newRandomPassword(); + String hashedNewPassword = WaoUtils.hashPassword(newPassword); + waoUser.setPassword(hashedNewPassword); + + sendNewPasswordToUser(waoUser, newPassword); + + getWaoUserDao().save(waoUser); + commit(); - save(updateWaoUserCommand); } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit 060144c9eb31e4d10a411585863b57568db81a88 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:16:55 2015 +0200 Ajout d'une valeur i18n manquante --- wao-web/src/main/resources/i18n/wao-web_en_GB.properties | 2 +- wao-web/src/main/resources/i18n/wao-web_fr_FR.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index 53cd06c..1ed6cc8 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -532,7 +532,7 @@ wao.ui.page.waoUsers.titleForCompany=Users for company %s wao.ui.periodToMustBeAfterPeriodFrom=The end of the period must be after the beginning wao.ui.publishedByProgram=Pusblished by program wao.ui.publishedByYourCompany=Published by company -wao.ui.reminderSent= +wao.ui.reminderSent=A new password has been sent, check out you inbox. wao.ui.removeBoatEligibility.confirm=Are you sure you want to make this boat ineligible for sample row ? wao.ui.sampleRow.creation=Creation of a sample row wao.ui.sampleRow.edition=Edition of line %s diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 18434ae..f0bba41 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -533,7 +533,7 @@ wao.ui.page.waoUsers.titleForCompany=Utilisateurs de la société %s wao.ui.periodToMustBeAfterPeriodFrom=La période de temps doit se terminer après avoir commencé wao.ui.publishedByProgram=Publiée par le programme wao.ui.publishedByYourCompany=Publiée par la société -wao.ui.reminderSent=Email de récupération du mot de passe envoyé, consultez votre boîte mail +wao.ui.reminderSent=Email de récupération du mot de passe envoyé, consultez votre boîte mail. wao.ui.removeBoatEligibility.confirm=Êtes-vous sûr de vouloir rendre le navire inéligible pour cette ligne ? wao.ui.sampleRow.creation=Création d'une ligne du plan d'échantillonnage wao.ui.sampleRow.edition=Modification de la ligne %s -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/6844-forgotenPassword in repository wao. See http://git.codelutin.com/wao.git commit 0afd3815f924c096f60ee24e84241b8be91b2023 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:21:30 2015 +0200 Suppression de code mort (?) --- wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp b/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp index 3aeb73b..8a39c9e 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/authentication/login.jsp @@ -32,11 +32,6 @@ $('input[name="login"]').focus(); }); </script> - <script type="text/javascript"> - function getLogin() { - return login = $('input[name="login"]').val(); - } - </script> </head> <body> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm