Commit db503a46 by Jan Hrabal

signup process

parent b872acb4
......@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.logging.ErrorManager;
import javax.servlet.http.HttpSession;
......@@ -119,22 +120,26 @@ public class AuthApiController {
//TODO validate email
if (!StringUtils.hasText(signup.getLogin())) {
errors.add(ErrorMessage.withFieldCode("username", "AUTH.BAD_USERNAME"));
errors.add(ErrorMessage.withFieldCode("login", "AUTH.BAD_USERNAME"));
}
if (!PasswordUtils.validatePassword(signup.getPassword())) {
errors.add(ErrorMessage.withFieldCode("password", "AUTH.BAD_PASSWORD"));
}
if (!Boolean.TRUE.equals(signup.getTerms())) {
errors.add(ErrorMessage.withFieldCode("terms", "AUTH.TERMS_REQUIRED"));
}
if (!Boolean.TRUE.equals(signup.getPrivacy())) {
errors.add(ErrorMessage.withFieldCode("privacy", "AUTH.PRIVACY_REQUIRED"));
}
if (!errors.isEmpty()) {
throw new RestApiException(HttpStatus.BAD_REQUEST, errors);
// throw new BadRequestException();
}
try {
authService.register(signup.getLogin(), signup.getPassword());
// Authentication auth = authService.authenticate(signup.getLogin(), signup.getPassword());
// SecurityContextHolder.getContext().setAuthentication(auth);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -36,19 +36,19 @@ public class Signup {
this.password = password;
}
public boolean isTerms() {
public Boolean getTerms() {
return terms;
}
public void setTerms(boolean terms) {
public void setTerms(Boolean terms) {
this.terms = terms;
}
public boolean isPrivacy() {
public Boolean getPrivacy() {
return privacy;
}
public void setPrivacy(boolean privacy) {
public void setPrivacy(Boolean privacy) {
this.privacy = privacy;
}
......
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