raulgomis / beerstrap

Startup project designed to ease and accelerate software development. Ideal for startups and web developers who want to rapid-prototype and develop products within weeks.
http://raulgomis.github.io/beerstrap/
Apache License 2.0
28 stars 10 forks source link

Login with Email and Case Insensitive Input #19

Closed bwagner5 closed 9 years ago

bwagner5 commented 10 years ago

This pull request gets rid of the GrantedAuthorityImpl (deprecated) and replaces it with SimpleGrantedAuthority.

Added email address to user find query

Made email address and username query case insensitive

Modified .git-ignore to exclude the .sass-cache directory

raulgomis commented 10 years ago

Hi @bwagner5 Thanks for the PR. I think it is a great idea to validate using email or username (like Facebook does, for example). However, we should assure that users with case sensitive can't be created. Otherwise if users "admin" and "Admin" are created Admin won't never be able to login.

bwagner5 commented 10 years ago

ah yes, I can solve this by implementing setUsername(String username) or a custom validator:

setUsername(String username){
    this.username = username.toLowerCase()
}

--or--

a custom validator could be created:

username(blank: false, unique: true, validator: { val, obj ->
                  def userChk = User.findByUsernameILike(val) 
                  return !userChk || obj.id == userChk.id
                })

Let me know which one you would prefer or another suggestion if you think there is a more elegant solution. I added a commit that implements the setUsername method in User.groovy. I think this is the most elegant solution compared to implementing a custom validator with a GORM query.

bwagner5 commented 10 years ago

@raulgomis is the fix that I committed acceptable?

raulgomis commented 10 years ago

Hi @bwagner5...yes! I want to review the code and implement some unit / integration tests if possible. I have been working on this last weekend, have some advances. I will merge it asap! thanks!