Note that there are some explanatory texts on larger screens.

plurals
  1. POValidating encrypted passwords in grails
    text
    copied!<p>In grails I can set the password field to have a minimum size constraint of 5 (arbitrary). The problem is that I use spring security service to encode my password and the encoded/encrypted password is much longer than 5 characters almost no matter what value I put in.</p> <p>Another forum response suggested doing that validation in the save method. Has anyone else tackled this problem and knows a way around it?</p> <p>Spring security does not provide a decode method (probably for security purposes)... so I guess one idea would be to get a different password encoder that could decode the password for validation purposes... but my instinct says that spring security leaves this out for a good reason and maybe I should too...</p> <pre><code>static constraints = { username(blank: false, unique: true) password(minSize: 5, blank: false, unique: true, validator: { passwd, user -&gt; return passwd != user.username }) passwordRepeat(nullable: false, validator: { passwd2, user -&gt; return passwd2 == user.password }) } </code></pre> <p>So I'm using the static constraints to validate as most other variables are validated this way.</p> <p>My apologies for the unreadable comment.</p> <p>Thank you, -Asaf</p> <p>Edit: I think a simple fix is as mentioned above, doing the validation in the save method (before encryption), but I just feel like someone somewhere must have had to deal with this issue before. I mean there's so many websites that require passwords and that yell at you if it's too short, if it doesn't contain both lowercase and uppercase letters, if it doesn't have a symbol... How do all of them do the various validation methods they use?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload