branch develop updated (37bdcc1 -> 2107c8d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from 37bdcc1 Refs-60 #6547: Change display of question, document, referential and users pages new 908e179 add rest services to generate new password and send it by mail new cbfefbf add ui for forgotten password new c5b48f8 Merge branch 'feature/6439-reinit-password' into develop new 2107c8d Merge branch 'develop' of https://git.codelutin.com/coselmar into develop The 4 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 2107c8da7c2d088ecaf28315470137ad6abb8145 Merge: c5b48f8 37bdcc1 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:57 2015 +0100 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop commit c5b48f80acb78501625412961663ad3c65b83159 Merge: dcd3eff cbfefbf Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:20 2015 +0100 Merge branch 'feature/6439-reinit-password' into develop commit cbfefbfa05fa15d236e7cc4a8f45713b8ae5c28e Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:06 2015 +0100 add ui for forgotten password commit 908e1799a2cc2a65d4cdb01eab7e87b64e62fc29 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 15:15:20 2015 +0100 add rest services to generate new password and send it by mail Summary of changes: ...erAccountCreatedMail.java => AbstractMail.java} | 33 ++-------------- ...countCreatedMail.java => LostPasswordMail.java} | 46 +++------------------- .../coselmar/beans/UserAccountCreatedMail.java | 40 +------------------ .../coselmar/services/v1/UsersWebService.java | 39 +++++++++++++++--- .../main/resources/mail/LostPasswordMail.mustache | 13 ++++++ .../resources/mail/LostPasswordMail_fr.mustache | 13 ++++++ coselmar-rest/src/main/resources/mapping | 1 + .../coselmar/services/UsersWebServiceTest.java | 23 +++++++++++ coselmar-ui/src/main/webapp/i18n/en.js | 7 ++++ coselmar-ui/src/main/webapp/i18n/fr.js | 7 ++++ coselmar-ui/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 31 ++++++++++++++- .../src/main/webapp/js/coselmar-user-services.js | 18 ++++++++- coselmar-ui/src/main/webapp/js/coselmar.js | 6 ++- .../src/main/webapp/views/users/newPassword.html | 30 ++++++++++++++ 15 files changed, 191 insertions(+), 118 deletions(-) copy coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/{UserAccountCreatedMail.java => AbstractMail.java} (65%) copy coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/{UserAccountCreatedMail.java => LostPasswordMail.java} (58%) create mode 100644 coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache create mode 100644 coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache create mode 100644 coselmar-ui/src/main/webapp/views/users/newPassword.html -- 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 develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 908e1799a2cc2a65d4cdb01eab7e87b64e62fc29 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 15:15:20 2015 +0100 add rest services to generate new password and send it by mail --- ...erAccountCreatedMail.java => AbstractMail.java} | 33 ++-------------- ...countCreatedMail.java => LostPasswordMail.java} | 46 +++------------------- .../coselmar/beans/UserAccountCreatedMail.java | 40 +------------------ .../coselmar/services/v1/UsersWebService.java | 39 +++++++++++++++--- .../main/resources/mail/LostPasswordMail.mustache | 13 ++++++ .../resources/mail/LostPasswordMail_fr.mustache | 13 ++++++ coselmar-rest/src/main/resources/mapping | 1 + .../coselmar/services/UsersWebServiceTest.java | 23 +++++++++++ 8 files changed, 94 insertions(+), 114 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/AbstractMail.java similarity index 65% copy from coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java copy to coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/AbstractMail.java index 8282746..7d96ab0 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/AbstractMail.java @@ -26,26 +26,21 @@ package fr.ifremer.coselmar.beans; import java.util.Locale; -import com.google.common.base.Strings; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import org.nuiton.i18n.I18n; /** * @author ymartel <martel@codelutin.com> */ -public class UserAccountCreatedMail { +public abstract class AbstractMail { protected Locale locale; protected String to; - private UserBean user; - private String coselmarUrl; - private String password; - public UserAccountCreatedMail(Locale locale) { + public AbstractMail(Locale locale) { this.locale = locale; } @@ -61,13 +56,7 @@ public class UserAccountCreatedMail { this.to = mail; } - public String getSubject() { - String fullname = Strings.nullToEmpty(user.getFirstName()) + " " + Strings.nullToEmpty(user.getName()); - if (StringUtils.isBlank(fullname)) { - return I18n.l(locale, "coselmar.service.mail.UserAccountCreatedMail.subject", user.getMail()); - } - return I18n.l(locale, "coselmar.service.mail.UserAccountCreatedMail.subject", fullname); - } + abstract public String getSubject(); @Override public String toString() { @@ -79,14 +68,6 @@ public class UserAccountCreatedMail { return isRecipientProvided; } - public UserBean getUser() { - return user; - } - - public void setUser(UserBean user) { - this.user = user; - } - public String getCoselmarUrl() { return coselmarUrl; } @@ -94,12 +75,4 @@ public class UserAccountCreatedMail { public void setCoselmarUrl(String coselmarUrl) { this.coselmarUrl = coselmarUrl; } - - public String getPassword () { - return password; - } - - public void setPassword (String password) { - this.password = password; - } } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/LostPasswordMail.java similarity index 58% copy from coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java copy to coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/LostPasswordMail.java index 8282746..5665653 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/LostPasswordMail.java @@ -28,55 +28,27 @@ import java.util.Locale; import com.google.common.base.Strings; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.nuiton.i18n.I18n; /** * @author ymartel <martel@codelutin.com> */ -public class UserAccountCreatedMail { - - protected Locale locale; - - protected String to; +public class LostPasswordMail extends AbstractMail { private UserBean user; - private String coselmarUrl; private String password; - public UserAccountCreatedMail(Locale locale) { - this.locale = locale; - } - - public Locale getLocale() { - return locale; - } - - public String getTo() { - return to; - } - - public void setTo(String mail) { - this.to = mail; + public LostPasswordMail(Locale locale) { + super(locale); } public String getSubject() { String fullname = Strings.nullToEmpty(user.getFirstName()) + " " + Strings.nullToEmpty(user.getName()); if (StringUtils.isBlank(fullname)) { - return I18n.l(locale, "coselmar.service.mail.UserAccountCreatedMail.subject", user.getMail()); + return I18n.l(locale, "coselmar.service.mail.LostPasswordMail.subject", user.getMail()); } - return I18n.l(locale, "coselmar.service.mail.UserAccountCreatedMail.subject", fullname); - } - - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this); - } - - public boolean isRecipientProvided() { - boolean isRecipientProvided = StringUtils.isNotBlank(this.to); - return isRecipientProvided; + return I18n.l(locale, "coselmar.service.mail.LostPasswordMail.subject", fullname); } public UserBean getUser() { @@ -87,14 +59,6 @@ public class UserAccountCreatedMail { this.user = user; } - public String getCoselmarUrl() { - return coselmarUrl; - } - - public void setCoselmarUrl(String coselmarUrl) { - this.coselmarUrl = coselmarUrl; - } - public String getPassword () { return password; } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java index 8282746..a810c30 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserAccountCreatedMail.java @@ -28,37 +28,19 @@ import java.util.Locale; import com.google.common.base.Strings; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.nuiton.i18n.I18n; /** * @author ymartel <martel@codelutin.com> */ -public class UserAccountCreatedMail { - - protected Locale locale; - - protected String to; +public class UserAccountCreatedMail extends AbstractMail { private UserBean user; - private String coselmarUrl; private String password; public UserAccountCreatedMail(Locale locale) { - this.locale = locale; - } - - public Locale getLocale() { - return locale; - } - - public String getTo() { - return to; - } - - public void setTo(String mail) { - this.to = mail; + super(locale); } public String getSubject() { @@ -69,16 +51,6 @@ public class UserAccountCreatedMail { return I18n.l(locale, "coselmar.service.mail.UserAccountCreatedMail.subject", fullname); } - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this); - } - - public boolean isRecipientProvided() { - boolean isRecipientProvided = StringUtils.isNotBlank(this.to); - return isRecipientProvided; - } - public UserBean getUser() { return user; } @@ -87,14 +59,6 @@ public class UserAccountCreatedMail { this.user = user; } - public String getCoselmarUrl() { - return coselmarUrl; - } - - public void setCoselmarUrl(String coselmarUrl) { - this.coselmarUrl = coselmarUrl; - } - public String getPassword () { return password; } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java index bcf59fa..99f73f7 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java @@ -38,17 +38,19 @@ import com.github.mustachejava.Mustache; import com.github.mustachejava.MustacheException; import com.github.mustachejava.MustacheFactory; import com.google.common.base.Preconditions; +import fr.ifremer.coselmar.beans.AbstractMail; +import fr.ifremer.coselmar.beans.LostPasswordMail; import fr.ifremer.coselmar.beans.UserAccountCreatedMail; import fr.ifremer.coselmar.beans.UserBean; import fr.ifremer.coselmar.beans.UserSearchBean; import fr.ifremer.coselmar.beans.UserWebToken; +import fr.ifremer.coselmar.config.CoselmarServicesConfig; import fr.ifremer.coselmar.converter.BeanEntityConverter; +import fr.ifremer.coselmar.exceptions.CoselmarTechnicalException; import fr.ifremer.coselmar.persistence.SearchRequestBean; import fr.ifremer.coselmar.persistence.entity.CoselmarUser; import fr.ifremer.coselmar.persistence.entity.CoselmarUserRole; -import fr.ifremer.coselmar.exceptions.CoselmarTechnicalException; import fr.ifremer.coselmar.services.CoselmarWebServiceSupport; -import fr.ifremer.coselmar.config.CoselmarServicesConfig; import fr.ifremer.coselmar.services.errors.InvalidCredentialException; import fr.ifremer.coselmar.services.errors.UnauthorizedException; import org.apache.commons.io.Charsets; @@ -369,6 +371,33 @@ public class UsersWebService extends CoselmarWebServiceSupport { commit(); } + public void generateNewPassword(String userMail) { + // Retrieve user + CoselmarUser user = getCoselmarUserDao().forMailEquals(userMail).findUnique(); + + // create new password + String password = getServicesContext().generatePassword(); + + // Salt it, encode it ! + String salt = getServicesContext().generateSalt(); + String encodedPassword = getServicesContext().encodePassword(salt, password); + user.setPassword(encodedPassword); + user.setSalt(salt); + + // commit, and send mail ! + commit(); + + LostPasswordMail lostPasswordMail = new LostPasswordMail(getServicesContext().getLocale()); + String shortId = getPersistenceContext().getTopiaIdFactory().getRandomPart(user.getTopiaId()); + UserBean userBean = BeanEntityConverter.toBean(shortId, user); + lostPasswordMail.setUser(userBean); + lostPasswordMail.setPassword(password); + lostPasswordMail.setTo(user.getMail()); + + sendMail(lostPasswordMail); + + } + ///////////////////////////////////////////// ///////////// Internal Part ///////// ///////////////////////////////////////////// @@ -416,7 +445,7 @@ public class UsersWebService extends CoselmarWebServiceSupport { /////////////// MAIL PART /////////////// ///////////////////////////////////////////// - protected void sendMail(UserAccountCreatedMail mail) { + protected void sendMail(AbstractMail mail) { if (getCoselmarServicesConfig().isDevMode()) { @@ -464,7 +493,7 @@ public class UsersWebService extends CoselmarWebServiceSupport { } } - protected String getBody(UserAccountCreatedMail mail) { + protected String getBody(AbstractMail mail) { Mustache mustache = getMustache(mail); StringWriter stringWriter = new StringWriter(); @@ -473,7 +502,7 @@ public class UsersWebService extends CoselmarWebServiceSupport { return stringWriter.toString(); } - protected Mustache getMustache(UserAccountCreatedMail mail) { + protected Mustache getMustache(AbstractMail mail) { MustacheFactory mustacheFactory = new DefaultMustacheFactory("mail/"); Locale locale = mail.getLocale(); diff --git a/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache b/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache new file mode 100644 index 0000000..15f319c --- /dev/null +++ b/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache @@ -0,0 +1,13 @@ +Dear {{user.name}}, + +A new password have been requested for you on the application. Please find below a new password to connect on Coselmar Platform : + +Password: {{password}} + +You can now change it from the Profile page in the application. + +Regards, + +Team Coselmar Platform. + +<a href="{{coselmarUrl}}">Coselmar Platform</a>. \ No newline at end of file diff --git a/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache b/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache new file mode 100644 index 0000000..1832e11 --- /dev/null +++ b/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache @@ -0,0 +1,13 @@ +Bonjour {{user.name}}, + +Suite à votre demande, un nouveau mot de passe a été généré : + +Password: {{password}} + +Vous pouvez le modifier depuis la page Profil de votre compte. + +Cordialement, + +L'équipe Coselmar Plateforme. + +<a href="{{coselmarUrl}}">Coselmar Plateforme</a>. \ No newline at end of file diff --git a/coselmar-rest/src/main/resources/mapping b/coselmar-rest/src/main/resources/mapping index 6fc2c64..f0fd0df 100644 --- a/coselmar-rest/src/main/resources/mapping +++ b/coselmar-rest/src/main/resources/mapping @@ -45,6 +45,7 @@ DELETE /v1/documents/{documentId} DocumentsWebService.deleteDocume GET /v1/users UsersWebService.getUsers GET /v1/users/{userId} UsersWebService.getUser POST /v1/users/login UsersWebService.login +POST /v1/users/password UsersWebService.generateNewPassword POST /v1/users/{userId} UsersWebService.modifyUser POST /v1/users UsersWebService.addUser DELETE /v1/users/{userId} UsersWebService.deleteUser diff --git a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/UsersWebServiceTest.java b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/UsersWebServiceTest.java index 7658d48..23ac5de 100644 --- a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/UsersWebServiceTest.java +++ b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/UsersWebServiceTest.java @@ -31,6 +31,7 @@ import com.auth0.jwt.JWTVerifier; import com.google.gson.Gson; import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; import org.junit.Assert; @@ -118,4 +119,26 @@ public class UsersWebServiceTest extends AbstractCoselmarWebServiceTest { String token = newUserLoginMap.get("jwt"); jwtVerifier.verify(token); } + + @Test + public void testGenerateNewPassword() throws Exception { + + Request newPasswordRequest = createRequest("/v1/users/password") + .addParameter("userMail", "lambda.expert@temporary.coselmar") + .Post(); + + Response newPasswordResponse = newPasswordRequest.execute(); + Assert.assertEquals(200, newPasswordResponse.returnResponse().getStatusLine().getStatusCode()); + + // Try log now + Request loginRequest = createRequest("/v1/users/login") + .addParameter("mail", "lambda.expert@temporary.coselmar") + .addParameter("password", "manager1234") + .Post(); + + Response loginResponse = loginRequest.execute(); + StatusLine loginStatusLine = loginResponse.returnResponse().getStatusLine(); + Assert.assertEquals(401, loginStatusLine.getStatusCode()); + + } } -- 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 develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit cbfefbfa05fa15d236e7cc4a8f45713b8ae5c28e Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:06 2015 +0100 add ui for forgotten password --- coselmar-ui/src/main/webapp/i18n/en.js | 7 +++++ coselmar-ui/src/main/webapp/i18n/fr.js | 7 +++++ coselmar-ui/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 31 +++++++++++++++++++++- .../src/main/webapp/js/coselmar-user-services.js | 18 ++++++++++++- coselmar-ui/src/main/webapp/js/coselmar.js | 6 ++++- .../src/main/webapp/views/users/newPassword.html | 30 +++++++++++++++++++++ 7 files changed, 97 insertions(+), 4 deletions(-) diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index 05c7320..91e9bdb 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -177,6 +177,7 @@ var translateEN = { <li>Client</li>\ </ul>", "user.create.client.info" : "Create new user with Client role", +"user.password.title" : "Send a new password", "user.metadata.name" : "Name", "user.metadata.firstName" : "First name", @@ -209,12 +210,17 @@ var translateEN = { "user.message.tooShortPassword" : "New password should contain at least 6 characters.", "user.message.passwordsNoMatch" : "The two new passwords don't match.", "user.message.login" : "Login :", +"user.message.forgotPassword" : "I forgot my password", +"user.message.enterMail" : "Please enter your email", +"user.message.unknownMail" : "This email does not exist.", +"user.message.newPasswordSent" : "A new password has been sent.", "user.button.add" : "Add an user", "user.button.add.client" : "Add a client", "user.button.disable" : "Disable", "user.button.enable" : "Enable", "user.button.showDisable" : "Show disable", +"user.button.newPassword" : "Send", //Referential part @@ -252,5 +258,6 @@ var translateEN = { "common.message.missingMandatoryFields" : "Some mandatory field (*) have not been filled.", "common.message.notYetAvailable" : "Not yet available.", "common.message.mandatoryFieldsInfo" : "Field with <strong><big>*</big></strong> are mandatory.", +"common.message.internalError" : "Error during process. If this problem persist, please contact application admin", } \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index 690884f..fbc9b04 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -177,6 +177,7 @@ var translateFR = { <li>Client</li>\ </ul>", "user.create.client.info" : "Créer un nouvel utilisateur de rôle \"Client\"", +"user.password.title" : "Envoi d'un nouveau mot de passe", "user.metadata.name" : "Nom", "user.metadata.firstName" : "Prénom", @@ -209,12 +210,17 @@ var translateFR = { "user.message.tooShortPassword" : "Le nouveau mot de passe doit contenir au moins 6 caractères.", "user.message.passwordsNoMatch" : "Les deux mots de passe entrés sont différents.", "user.message.login" : "Connectez-vous :", +"user.message.forgotPassword" : "J'ai oublié mon mot de passe", +"user.message.enterMail" : "Veuillez entrer votre courriel", +"user.message.unknownMail" : "Ce courriel est inconnu.", +"user.message.newPasswordSent" : "Un nouveau mot de passe a été envoyé.", "user.button.add" : "Ajouter un utilisateur", "user.button.add.client" : "Ajouter un client", "user.button.disable" : "Désactiver", "user.button.enable" : "Activer", "user.button.showDisable" : "Montrer les désactivés", +"user.button.newPassword" : "Envoyer", //Referential part @@ -252,5 +258,6 @@ var translateFR = { "common.message.missingMandatoryFields" : "Certains champs obligatoires (*) n'ont pas été remplis.", "common.message.notYetAvailable" : "Pas encore disponible.", "common.message.mandatoryFieldsInfo" : "Les champs avec un <strong><big>*</big></strong> sont obligatoires.", +"common.message.internalError" : "Erreur durant le traitement. Si le problème persiste, veuillez contacter l'administrateur de l'application.", } \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index 088f5bf..ffbdc16 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -111,7 +111,7 @@ <!-- Login Part --> <form class="navbar-form navbar-right" role="form" ng-if="!currentUser"> <div class="user-info"> - {{ 'user.message.login' | translate}} + {{ 'user.message.login' | translate}} (<a href="#/users/forgotPassword">{{ 'user.message.forgotPassword' | translate }}</a> ) </div> <div class="form-group"> <input type="text" placeholder="Mail" class="form-control" ng-model="loginMail"> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 3e8033e..1c6db12 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -21,7 +21,7 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -var coselmarControllers = angular.module('coselmarControllers', ['ui.bootstrap', 'ui.select', 'ui.bootstrap.tooltip']); +var coselmarControllers = angular.module('coselmarControllers', ['ui.bootstrap', 'ui.select', 'ui.bootstrap.tooltip', 'pascalprecht.translate']); // Controller when the main page/view loads coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$routeParams', '$locale', '$translate', 'userService', 'jwtHelper', 'coselmar-config', @@ -483,6 +483,35 @@ coselmarControllers.controller("UserViewCtrl", } ]); +coselmarControllers.controller("NewPasswordCtrl", ['$scope', '$translate', 'userService', function($scope, $translate, userService){ + + $scope.alerts = []; + + $scope.closeAlert = function(index) { + $scope.alerts.splice(index, 1); + }; + + $scope.sendPassword = function(){ + + // Call service to create a new user + if($scope.mail) { + userService.sendNewPassword($scope.mail, function() { + $scope.alerts.push({ type : 'success', msg : "user.message.newPasswordSent"}); + delete $scope.mail; + }, function(error) { + if (error.status == 404) { + $scope.alerts.push({ type : 'danger', msg : "user.message.unknownMail"}); + } else { + $scope.alerts.push({ type : 'danger', msg : "common.message.internalError"}); + } + }); + } else { + $scope.alerts.push({ type : 'danger', msg : "user.message.enterMail"}); + }; + + }; +}]); + // This directive checks two inputs have identical values. // This is used for new password check coselmarControllers.directive('identicalCheck', [function () { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index efd0c70..850dcd6 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -90,6 +90,22 @@ function User(resource, config){ }, }}); userResource.post(credentials, successFunction, failFunction); - } + }; + + this.sendNewPassword = function(mail, successFunction, failFunction){ + + var params = $.param({ + 'userMail' : mail + }); + + var userResource = resource(baseURL + "/password", null, { + 'post' : { + method: 'POST', + headers : { + 'Content-Type' : 'application/x-www-form-urlencoded;charset=utf-8' + }, + }}); + userResource.post(params, successFunction, failFunction); + }; }; \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/js/coselmar.js b/coselmar-ui/src/main/webapp/js/coselmar.js index eb3b393..788b3a9 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar.js +++ b/coselmar-ui/src/main/webapp/js/coselmar.js @@ -48,6 +48,10 @@ coselmarApp.config(['$routeProvider', function($routeProvider) { controller : 'NewUserCtrl', templateUrl : 'views/users/newuser.html' + }).when('/users/forgotPassword', { + controller : 'NewPasswordCtrl', + templateUrl : 'views/users/newPassword.html' + }).when('/users/:userId', { controller : 'UserViewCtrl', templateUrl : 'views/users/user.html' @@ -117,7 +121,7 @@ coselmarApp.config(function($httpProvider) { $location.path("/403"); } else if (rejection.status == 404) { - $location.path("/404"); +// $location.path("/404"); } else { $location.path("/"); diff --git a/coselmar-ui/src/main/webapp/views/users/newPassword.html b/coselmar-ui/src/main/webapp/views/users/newPassword.html new file mode 100644 index 0000000..bb6f23f --- /dev/null +++ b/coselmar-ui/src/main/webapp/views/users/newPassword.html @@ -0,0 +1,30 @@ +<div class="page-header"> + <h2> + <!-- Heading goes here --> + {{ 'user.password.title' | translate }} + </h2> +</div> + +<div class="text-center"> + <alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg | translate}}</alert> +</div> + +<div class="text-center"> + + <form name="newPasswordForm" class="form-inline" role="form" ng-submit="sendPassword()"> + <div class="form-group"> + <label class="control-label">{{ 'user.message.enterMail' | translate }}</label> + + <input type="email" class="form-control" name="mail" + placeholder="james.bond@mi6.org" ng-model="mail" required/> + </div> + + + <div class="form-group"> + <div class="float-right col-md-4"> + <input type="submit" value="{{'user.button.newPassword' | translate}}" class="btn btn-primary" /> + </div> + </div> + + </form> +</div> \ No newline at end of file -- 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 develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit c5b48f80acb78501625412961663ad3c65b83159 Merge: dcd3eff cbfefbf Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:20 2015 +0100 Merge branch 'feature/6439-reinit-password' into develop ...erAccountCreatedMail.java => AbstractMail.java} | 33 ++-------------- ...countCreatedMail.java => LostPasswordMail.java} | 46 +++------------------- .../coselmar/beans/UserAccountCreatedMail.java | 40 +------------------ .../coselmar/services/v1/UsersWebService.java | 39 +++++++++++++++--- .../main/resources/mail/LostPasswordMail.mustache | 13 ++++++ .../resources/mail/LostPasswordMail_fr.mustache | 13 ++++++ coselmar-rest/src/main/resources/mapping | 1 + .../coselmar/services/UsersWebServiceTest.java | 23 +++++++++++ coselmar-ui/src/main/webapp/i18n/en.js | 7 ++++ coselmar-ui/src/main/webapp/i18n/fr.js | 7 ++++ coselmar-ui/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 31 ++++++++++++++- .../src/main/webapp/js/coselmar-user-services.js | 18 ++++++++- coselmar-ui/src/main/webapp/js/coselmar.js | 6 ++- .../src/main/webapp/views/users/newPassword.html | 30 ++++++++++++++ 15 files changed, 191 insertions(+), 118 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 develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 2107c8da7c2d088ecaf28315470137ad6abb8145 Merge: c5b48f8 37bdcc1 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Jan 28 17:47:57 2015 +0100 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop coselmar-ui/src/main/webapp/css/coselmar.css | 39 +++++++- .../src/main/webapp/views/documents/documents.html | 53 +++++----- .../src/main/webapp/views/questions/questions.html | 98 ++++++++++--------- .../main/webapp/views/questions/viewquestion.html | 107 ++++++++++++--------- .../main/webapp/views/referential/referential.html | 78 ++++++++------- .../src/main/webapp/views/users/adminUsers.html | 104 +++++++------------- .../src/main/webapp/views/users/searchPart.html | 20 ++-- .../main/webapp/views/users/supervisorUsers.html | 73 +++++++------- 8 files changed, 308 insertions(+), 264 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm