mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
make sure emails are unique
This commit is contained in:
@@ -66,7 +66,7 @@ public class PasswordRecoveryCallbackPage extends BasePage {
|
||||
userDAO.update(user);
|
||||
info("Password saved.");
|
||||
} else {
|
||||
error("Password do not match");
|
||||
error("Passwords do not match.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -98,7 +98,18 @@ public class RegisterPanel extends Panel {
|
||||
protected String getInputType() {
|
||||
return "email";
|
||||
}
|
||||
}.add(RfcCompliantEmailAddressValidator.getInstance()));
|
||||
}.add(RfcCompliantEmailAddressValidator.getInstance()).add(
|
||||
new IValidator<String>() {
|
||||
@Override
|
||||
public void validate(IValidatable<String> validatable) {
|
||||
String email = validatable.getValue();
|
||||
User user = userDAO.findByEmail(email);
|
||||
if (user != null) {
|
||||
validatable.error(new ValidationError(
|
||||
"Email is already taken."));
|
||||
}
|
||||
}
|
||||
}));
|
||||
form.add(new CheckBox("import", MF.m(model, p.isGoogleImport())));
|
||||
|
||||
}
|
||||
|
||||
@@ -108,6 +108,15 @@ public class UserREST extends AbstractResourceREST {
|
||||
public Response save(
|
||||
@ApiParam(required = true) ProfileModificationRequest request) {
|
||||
User user = getUser();
|
||||
|
||||
Preconditions.checkArgument(StringUtils.isBlank(request.getPassword())
|
||||
|| request.getPassword().length() >= 6);
|
||||
if (StringUtils.isNotBlank(request.getEmail())) {
|
||||
User u = userDAO.findByEmail(request.getEmail());
|
||||
Preconditions.checkArgument(u == null
|
||||
|| user.getId().equals(u.getId()));
|
||||
}
|
||||
|
||||
if (StartupBean.USERNAME_DEMO.equals(user.getName())) {
|
||||
return Response.status(Status.UNAUTHORIZED).build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user