--- a/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java Wed Oct 23 01:43:09 2013 +0200
+++ b/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java Thu Oct 24 13:40:35 2013 +0200
@@ -106,8 +106,8 @@
try {
userForm.save();
} catch (RenkanException e) {
- throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "space "
- + userForm.getId() + " not found");
+ throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "user "
+ + userForm.getId()==null?"":userForm.getId() + " not found");
}
return "redirect:/admin/users";
--- a/server/src/main/java/org/iri_research/renkan/forms/UserForm.java Wed Oct 23 01:43:09 2013 +0200
+++ b/server/src/main/java/org/iri_research/renkan/forms/UserForm.java Thu Oct 24 13:40:35 2013 +0200
@@ -2,11 +2,15 @@
import java.util.Date;
+import javax.inject.Inject;
+import javax.inject.Named;
+
import org.iri_research.renkan.Constants;
import org.iri_research.renkan.models.User;
import org.iri_research.renkan.repositories.IRenkanRepository;
import org.iri_research.renkan.repositories.UsersRepository;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
@Component
@@ -23,9 +27,14 @@
private boolean locked;
private String password;
private String passwordConfirm;
- @Autowired
+
+ @Inject
private UsersRepository usersRepository;
+ @Inject
+ @Named(value="renkanPasswordEncoder")
+ private PasswordEncoder passwordEncoder;
+
public UserForm() {
super();
@@ -100,7 +109,7 @@
this.model.setExpirationDate(this.expirationDate);
this.model.setEnabled(this.enabled);
this.model.setLocked(this.locked);
- this.model.setRawPassword(this.password);
+ this.model.setPassword(this.passwordEncoder.encode(this.password));
}
--- a/server/src/main/java/org/iri_research/renkan/models/User.java Wed Oct 23 01:43:09 2013 +0200
+++ b/server/src/main/java/org/iri_research/renkan/models/User.java Thu Oct 24 13:40:35 2013 +0200
@@ -20,9 +20,6 @@
private static final long serialVersionUID = 6972038893086220548L;
- @Resource(name="renkanPasswordEncoder")
- private PasswordEncoder passwordEncoder;
-
private String avatar;
@Field("credentials_expiration_date")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT")
@@ -138,8 +135,8 @@
return "";
}
- public void setRawPassword(String password) {
- this.password = this.passwordEncoder.encode(password);
+ public void setPassword(String password) {
+ this.password = password;
}
}
--- a/server/src/main/webapp/WEB-INF/templates/fragment/userForm.html Wed Oct 23 01:43:09 2013 +0200
+++ b/server/src/main/webapp/WEB-INF/templates/fragment/userForm.html Thu Oct 24 13:40:35 2013 +0200
@@ -82,10 +82,12 @@
<div>
<label for="password" th:text="#{renkanAdmin.form.password}">Password: </label>
<input type="password" th:field="*{password}" />
+ <div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="form-error"></div>
</div>
<div>
<label for="passwordConfirm" th:text="#{renkanAdmin.form.passwordConfirm}">Confirm password: </label>
<input type="password" th:field="*{passwordConfirm}" />
+ <div th:if="${#fields.hasErrors('passwordConfirm')}" th:errors="*{passwordConfirm}" class="form-error"></div>
</div>
<div>
<label for="credentialExpirationDate" th:text="#{renkanAdmin.form.credentialExpirationDate}">Credential expiration date: </label>