Commit 8ef38747 by Jan Hrabal

login field

parent bf9b9b45
......@@ -29,10 +29,11 @@ public interface AuthService {
/**
* Register.
* @param locale TODO
* @param signup the signup
*/
void register(String login, String password, Locale locale) throws AuthenticationException;
* @param signup the signup
* @param email
* @param locale TODO
*/
void register(String login, String email, String password, Locale locale) throws AuthenticationException;
/**
......
......@@ -129,7 +129,11 @@ public class AuthApiController {
if (!StringUtils.hasText(signup.getLogin())) {
errors.add(ErrorMessage.withFieldCode("login", "AUTH.BAD_USERNAME"));
}
if (!StringUtils.hasText(signup.getEmail())) {
errors.add(ErrorMessage.withFieldCode("email", "AUTH.BAD_EMAIL"));
}
if (!PasswordUtils.validatePassword(signup.getPassword())) {
errors.add(ErrorMessage.withFieldCode("password", "AUTH.BAD_PASSWORD"));
}
......@@ -146,7 +150,7 @@ public class AuthApiController {
}
try {
authService.register(signup.getLogin(), signup.getPassword(), locale);
authService.register(signup.getLogin(), signup.getEmail(), signup.getPassword(), locale);
} catch (BadCredentialsException e) {
errors.add(ErrorMessage.withCode(e.getMessage()));
} catch (Exception e) {
......
......@@ -4,6 +4,8 @@ public class Signup {
private String login;
private String email;
private String password;
private Boolean terms;
......@@ -20,6 +22,13 @@ public class Signup {
this.password = password;
}
public Signup(String login, String email, String password) {
super();
this.login = login;
this.email = email;
this.password = password;
}
public String getLogin() {
return login;
}
......@@ -52,4 +61,11 @@ public class Signup {
this.privacy = privacy;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
......@@ -69,7 +69,7 @@ public class AppUserAuthService implements AuthService {
@Override
@Transactional
public void register(String login, String password, Locale locale) throws AuthenticationException {
public void register(String login, String email, String password, Locale locale) throws AuthenticationException {
AppUser user = appUserRepository.findByLogin(login);
if (user != null) {
throw new BadCredentialsException("AUTH.USER_ALREADY_EXISTS");
......
......@@ -81,7 +81,7 @@ public class TemplateEmailAuthServiceListener implements AuthServiceListener {
html = templateService.evaluate(html, data, locale);
Email email = new Email();
email.setRecipients(Collections.singleton(new EmailRecipient(user.getLogin(), RecipientType.TO)));
email.setRecipients(Collections.singleton(new EmailRecipient(user.getEmail(), RecipientType.TO)));
email.setSubject(subject);
email.setText(content);
email.setHtml(html);
......
Markdown is supported
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