Guest User

Untitled

a guest
Jan 15th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. class User {
  2. // Added by the spring security core plugin
  3. String password
  4. // Added by me
  5. String passwordConfirm
  6.  
  7. static constraints = {
  8. passwordConfirm blank:false, validator: { val, obj ->
  9. if (!obj.password.equals(obj.passwordConfirm)) {
  10. return "user.password.confirmation.error"
  11. }
  12. }
  13. }
  14.  
  15. // other methods...
  16. }
  17.  
  18. org.hibernate.AssertionFailure: null id in com.test.User entry (don't flush the Session after an exception occurs)
  19.  
  20. at com.shopify.RegistrationController$_closure2.doCall(RegistrationController.groovy:14)
  21.  
  22. at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
  23.  
  24. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
  25.  
  26. at java.lang.Thread.run(Thread.java:680)
  27.  
  28. def register = {
  29. def user = new User(params)
  30. if (!user.save(flush:true, failOnError:true)) {
  31. render view: 'register', model: [userInstance: user]
  32. } else {
  33. render view: 'success'
  34. }
  35. }
  36.  
  37. def beforeInsert() {
  38. // encodePassword()
  39. }
  40.  
  41. def beforeUpdate() {
  42. // if (isDirty('password')) {
  43. // encodePassword()
  44. // }
  45. }
  46.  
  47. def password = 1234
  48. def passwordConfirm = 1234
  49. password == passwordConfirm validation passes
  50.  
  51. def password gets hashed:
  52. def password = 1JO@J$O!@J$P!O@$JP!@O$J!@O$J!@
  53. def passwordConfirm = 1234
  54. password != passwordConfirm validation fails
  55.  
  56. def password = 1234
  57. def passwordConfirm = 1234
  58. password == passwordConfirm validation passes but now you have your password in plain texts inside your DB, you should never do this for security reasons.
Add Comment
Please, Sign In to add comment