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 28e53d21aa0088e5bd70b2de9105c49f98e2cee3 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 29 18:25:41 2015 +0100 fixes #6579 fix mails subject and body --- .../coselmar/config/CoselmarServicesConfig.java | 4 ++ .../config/CoselmarServicesConfigOption.java | 5 ++ .../coselmar/beans/UserPasswordChangedMail.java | 69 ++++++++++++++++++++++ .../coselmar/services/v1/UsersWebService.java | 15 +++-- .../i18n/coselmar-services_en_GB.properties | 4 +- .../i18n/coselmar-services_fr_FR.properties | 4 +- .../main/resources/mail/LostPasswordMail.mustache | 2 +- .../resources/mail/LostPasswordMail_fr.mustache | 4 +- .../resources/mail/UserAccountCreatedMail.mustache | 4 +- .../mail/UserAccountCreatedMail_fr.mustache | 4 +- .../mail/UserPasswordChangedMail.mustache | 13 ++++ .../mail/UserPasswordChangedMail_fr.mustache | 13 ++++ 12 files changed, 126 insertions(+), 15 deletions(-) diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfig.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfig.java index 4b597b5..d3fa398 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfig.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfig.java @@ -147,6 +147,10 @@ public class CoselmarServicesConfig { return isDevMode; } + public String getApplicationUrl() { + return applicationConfig.getOption(CoselmarServicesConfigOption.APPLICATION_URL.key); + } + public String getWebSecurityKey() { return applicationConfig.getOption(CoselmarServicesConfigOption.WEB_SECURITY_KEY.key); } diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfigOption.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfigOption.java index ca0808a..8cd0a9f 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfigOption.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/config/CoselmarServicesConfigOption.java @@ -71,6 +71,11 @@ public enum CoselmarServicesConfigOption implements ConfigOptionDef { "Mode développement, court-circuite l'envoi de mail", "true", Boolean.class), + APPLICATION_URL( + "coselmar.application.url", + "URL de l'application Coselmar, utilisée dans l'envoi de mail", + "", String.class), + WEB_SECURITY_KEY( "coselmar.web.security.key", "Clef de sécurity permettant d'encoder les token d'authentication", diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserPasswordChangedMail.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserPasswordChangedMail.java new file mode 100644 index 0000000..73a0ce9 --- /dev/null +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/UserPasswordChangedMail.java @@ -0,0 +1,69 @@ +package fr.ifremer.coselmar.beans; + +/* + * #%L + * Coselmar :: Rest Services + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2014 Ifremer, Code Lutin + * %% + * 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/gpl-3.0.html>. + * #L% + */ + +import java.util.Locale; + +import com.google.common.base.Strings; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.i18n.I18n; + +/** + * @author ymartel <martel@codelutin.com> + */ +public class UserPasswordChangedMail extends AbstractMail { + + private UserBean user; + + private String password; + + public UserPasswordChangedMail(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.UserPasswordChangedMail.subject", user.getMail()); + } + return I18n.l(locale, "coselmar.service.mail.UserPasswordChangedMail.subject", fullname); + } + + public UserBean getUser() { + return user; + } + + public void setUser(UserBean user) { + this.user = user; + } + + public String getPassword () { + return password; + } + + public void setPassword (String password) { + this.password = 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 99f73f7..a3deee0 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 @@ -42,6 +42,7 @@ 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.UserPasswordChangedMail; import fr.ifremer.coselmar.beans.UserSearchBean; import fr.ifremer.coselmar.beans.UserWebToken; import fr.ifremer.coselmar.config.CoselmarServicesConfig; @@ -302,12 +303,12 @@ public class UsersWebService extends CoselmarWebServiceSupport { coselmarUser.setPassword(encodedPassword); //if it is a modification by Admin, send new mail to user - if (isAdmin) { - UserAccountCreatedMail userAccountCreatedMail = new UserAccountCreatedMail(getServicesContext().getLocale()); - userAccountCreatedMail.setUser(user); - userAccountCreatedMail.setPassword(newPassword); - userAccountCreatedMail.setTo(coselmarUser.getMail()); - sendMail(userAccountCreatedMail); + if (isAdmin || isSupervisor4Client) { + UserPasswordChangedMail userPasswordChangedMail = new UserPasswordChangedMail(getServicesContext().getLocale()); + userPasswordChangedMail.setUser(user); + userPasswordChangedMail.setPassword(newPassword); + userPasswordChangedMail.setTo(coselmarUser.getMail()); + sendMail(userPasswordChangedMail); } } @@ -463,6 +464,8 @@ public class UsersWebService extends CoselmarWebServiceSupport { CoselmarServicesConfig applicationConfig = getCoselmarServicesConfig(); + mail.setCoselmarUrl(applicationConfig.getApplicationUrl()); + String body = getBody(mail); if (mail.isRecipientProvided()) { diff --git a/coselmar-rest/src/main/resources/i18n/coselmar-services_en_GB.properties b/coselmar-rest/src/main/resources/i18n/coselmar-services_en_GB.properties index 4fbad7d..edf8993 100644 --- a/coselmar-rest/src/main/resources/i18n/coselmar-services_en_GB.properties +++ b/coselmar-rest/src/main/resources/i18n/coselmar-services_en_GB.properties @@ -1 +1,3 @@ -coselmar.service.mail.UserAccountCreatedMail.subject=[Coselmar] Account creation %s \ No newline at end of file +coselmar.service.mail.UserAccountCreatedMail.subject=[Coselmar] Account creation %s +coselmar.service.mail.PasswordChangedMail.subject=[Coselmar] Password has been changed +coselmar.service.mail.LostPasswordMail.subject=[Coselmar] New password \ No newline at end of file diff --git a/coselmar-rest/src/main/resources/i18n/coselmar-services_fr_FR.properties b/coselmar-rest/src/main/resources/i18n/coselmar-services_fr_FR.properties index a445de0..04f2dbd 100644 --- a/coselmar-rest/src/main/resources/i18n/coselmar-services_fr_FR.properties +++ b/coselmar-rest/src/main/resources/i18n/coselmar-services_fr_FR.properties @@ -1 +1,3 @@ -coselmar.service.mail.UserAccountCreatedMail.subject=[Coselmar] Création du compte %s \ No newline at end of file +coselmar.service.mail.UserAccountCreatedMail.subject=[Coselmar] Création du compte %s +coselmar.service.mail.PasswordChangedMail.subject=[Coselmar] Mot de passe modifié +coselmar.service.mail.LostPasswordMail.subject=[Coselmar] Nouveau mot de passe \ No newline at end of file diff --git a/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache b/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache index 15f319c..e4e6b2e 100644 --- a/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache +++ b/coselmar-rest/src/main/resources/mail/LostPasswordMail.mustache @@ -1,4 +1,4 @@ -Dear {{user.name}}, +Dear {{user.firstName}} {{user.name}}, A new password have been requested for you on the application. Please find below a new password to connect on Coselmar Platform : diff --git a/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache b/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache index 1832e11..88ebdd4 100644 --- a/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache +++ b/coselmar-rest/src/main/resources/mail/LostPasswordMail_fr.mustache @@ -1,8 +1,8 @@ -Bonjour {{user.name}}, +Bonjour {{user.firstName}} {{user.name}}, Suite à votre demande, un nouveau mot de passe a été généré : -Password: {{password}} +Nouveau mot de passe: {{password}} Vous pouvez le modifier depuis la page Profil de votre compte. diff --git a/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail.mustache b/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail.mustache index cc66848..d745b61 100644 --- a/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail.mustache +++ b/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail.mustache @@ -1,8 +1,8 @@ -Welcome {{user.name}}, +Welcome {{user.firstName}} {{user.name}}, An account has been created for you on the web application Coselmar. Email: {{user.mail}} Password: {{password}} -You can now access to your account by logging on the <a href="{{coselmarUrl}}">Coselmar</a> website. \ No newline at end of file +You can now access to your account by logging on the <a href="{{coselmarUrl}}">Coselmar Platform</a>. \ No newline at end of file diff --git a/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail_fr.mustache b/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail_fr.mustache index c573235..ae94497 100644 --- a/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail_fr.mustache +++ b/coselmar-rest/src/main/resources/mail/UserAccountCreatedMail_fr.mustache @@ -1,8 +1,8 @@ -Bonjour {{user.name}}, +Bonjour {{user.firstName}} {{user.name}}, Un compte vous a été ouvert sur l'application Coselmar. Courriel: {{user.mail}} Password: {{password}} -Vous pouvez dès à présent accéder à l'application en vous connectant sur <a href="{{coselmarUrl}}">Coselmar</a>. \ No newline at end of file +Vous pouvez dès à présent accéder à l'application en vous connectant sur la <a href="{{coselmarUrl}}">Plateforme Coselmar</a>. \ No newline at end of file diff --git a/coselmar-rest/src/main/resources/mail/UserPasswordChangedMail.mustache b/coselmar-rest/src/main/resources/mail/UserPasswordChangedMail.mustache new file mode 100644 index 0000000..9c45a57 --- /dev/null +++ b/coselmar-rest/src/main/resources/mail/UserPasswordChangedMail.mustache @@ -0,0 +1,13 @@ +Dear {{user.firstName}} {{user.name}}, + +Your password on the application has been changed. 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/UserPasswordChangedMail_fr.mustache b/coselmar-rest/src/main/resources/mail/UserPasswordChangedMail_fr.mustache new file mode 100644 index 0000000..86de144 --- /dev/null +++ b/coselmar-rest/src/main/resources/mail/UserPasswordChangedMail_fr.mustache @@ -0,0 +1,13 @@ +Bonjour {{user.firstName}} {{user.name}}, + +Votre mot de passe sur l'application a été modifié : + +Nouveau mot de passe: {{password}} + +Vous pouvez le modifier depuis la page Profil de votre compte. + +Cordialement, + +L'équipe Coselmar Plateforme. + +<a href="{{coselmarUrl}}">Coselmar Plateforme</a>. -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.