Skip to content
Snippets Groups Projects
Commit 6857395b authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Simplify account mails and fix placeholders

The account activation and reset mail now only contain the code. String
placeholders are numbered correctly again. The activation key's length
has been reduced to 8 characters.

Fixes #47.
parent 9bbff2ed
No related merge requests found
...@@ -437,7 +437,7 @@ public class UserServiceImpl extends DefaultEntityServiceImpl<UserProfile> imple ...@@ -437,7 +437,7 @@ public class UserServiceImpl extends DefaultEntityServiceImpl<UserProfile> imple
userProfile.setAuthProvider(UserProfile.AuthProvider.ARSNOVA); userProfile.setAuthProvider(UserProfile.AuthProvider.ARSNOVA);
userProfile.setLoginId(lcUsername); userProfile.setLoginId(lcUsername);
account.setPassword(encodePassword(password)); account.setPassword(encodePassword(password));
account.setActivationKey(RandomStringUtils.randomAlphanumeric(32)); account.setActivationKey(RandomStringUtils.randomAlphanumeric(8));
userProfile.setCreationTimestamp(new Date()); userProfile.setCreationTimestamp(new Date());
/* Repository is accessed directly without EntityService to skip permission check */ /* Repository is accessed directly without EntityService to skip permission check */
...@@ -461,15 +461,9 @@ public class UserServiceImpl extends DefaultEntityServiceImpl<UserProfile> imple ...@@ -461,15 +461,9 @@ public class UserServiceImpl extends DefaultEntityServiceImpl<UserProfile> imple
private void sendActivationEmail(final UserProfile userProfile) { private void sendActivationEmail(final UserProfile userProfile) {
final String activationKey = userProfile.getAccount().getActivationKey(); final String activationKey = userProfile.getAccount().getActivationKey();
final String activationUrl = MessageFormat.format(
"{0}{1}/login?action=activate&username={3}&key={4}",
rootUrl,
customizationPath,
UriUtils.encodeQueryParam(userProfile.getLoginId(), "UTF-8"),
activationKey);
sendEmail(userProfile, registeredProperties.getRegistrationMailSubject(), sendEmail(userProfile, registeredProperties.getRegistrationMailSubject(),
MessageFormat.format(registeredProperties.getRegistrationMailBody(), activationUrl, activationKey)); MessageFormat.format(registeredProperties.getRegistrationMailBody(), activationKey, rootUrl));
} }
private void parseMailAddressPattern() { private void parseMailAddressPattern() {
...@@ -569,20 +563,8 @@ public class UserServiceImpl extends DefaultEntityServiceImpl<UserProfile> imple ...@@ -569,20 +563,8 @@ public class UserServiceImpl extends DefaultEntityServiceImpl<UserProfile> imple
logger.error("Password reset failed. {} could not be updated.", username); logger.error("Password reset failed. {} could not be updated.", username);
} }
final String resetPasswordUrl = MessageFormat.format( sendEmail(userProfile, registeredProperties.getResetPasswordMailSubject(), MessageFormat.format(
"{0}{1}/login?action=resetpassword&username={3}&key={4}", registeredProperties.getResetPasswordMailBody(), account.getPasswordResetKey(), rootUrl));
rootUrl,
customizationPath,
UriUtils.encodeQueryParam(userProfile.getLoginId(), "UTF-8"), account.getPasswordResetKey());
final String mailBody = MessageFormat.format(
registeredProperties.getResetPasswordMailBody(),
resetPasswordUrl,
account.getPasswordResetKey()
);
sendEmail(userProfile, registeredProperties.getResetPasswordMailSubject(),
MessageFormat.format(mailBody, resetPasswordUrl));
} }
@Override @Override
......
...@@ -107,16 +107,20 @@ arsnova: ...@@ -107,16 +107,20 @@ arsnova:
registration-mail-body: |- registration-mail-body: |-
Welcome to ARSnova! Welcome to ARSnova!
Please confirm your registration by visiting the following web address: Here is the activation code you need for your first login to ARSnova:
{0}
Afterwards, you can log into ARSnova with your e-mail address and password. {0}
{1}
reset-password-mail-subject: ARSnova Password Reset reset-password-mail-subject: ARSnova Password Reset
reset-password-mail-body: |- reset-password-mail-body: |-
You requested to reset your password. You requested to reset your password.
Please follow the link below to set a new password: Here is the confirmation code you need to set a new password:
{0}
{0}
{1}
# LDAP authentication # LDAP authentication
# #
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment