# HG changeset patch # User ymh # Date 1382614835 -7200 # Node ID 0877747b02138711d6eda986791b1b100bf0f2f5 # Parent d2b688aadd8c4baaba4bfd3be4a0dcc6d77e10ac put password encoder where it can be injected diff -r d2b688aadd8c -r 0877747b0213 server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java --- 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"; diff -r d2b688aadd8c -r 0877747b0213 server/src/main/java/org/iri_research/renkan/forms/UserForm.java --- 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)); } diff -r d2b688aadd8c -r 0877747b0213 server/src/main/java/org/iri_research/renkan/models/User.java --- 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; } } diff -r d2b688aadd8c -r 0877747b0213 server/src/main/webapp/WEB-INF/templates/fragment/userForm.html --- 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 @@
+
+