Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
Merge pull request #20 from apexskier/hash-change
Browse files Browse the repository at this point in the history
Removed password hashing on username.
  • Loading branch information
apexskier committed Apr 7, 2015
2 parents 4469121 + 0b1dddb commit 2f12751
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (a Authorizer) Login(rw http.ResponseWriter, req *http.Request, u string, p
return mkerror("already authenticated")
}
if user, err := a.backend.User(u); err == nil {
verify := bcrypt.CompareHashAndPassword(user.Hash, []byte(u+p))
verify := bcrypt.CompareHashAndPassword(user.Hash, []byte(p))
if verify != nil {
a.addMessage(rw, req, "Invalid username or password.")
return mkerror("password doesn't match")
Expand Down Expand Up @@ -174,7 +174,7 @@ func (a Authorizer) Register(rw http.ResponseWriter, req *http.Request, user Use
}

// Generate and save hash
hash, err := bcrypt.GenerateFromPassword([]byte(user.Username+password), bcrypt.DefaultCost)
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return mkerror("couldn't save password: " + err.Error())
}
Expand Down Expand Up @@ -216,7 +216,7 @@ func (a Authorizer) Update(rw http.ResponseWriter, req *http.Request, p string,
return mkerror(err.Error())
}
if p != "" {
hash, err = bcrypt.GenerateFromPassword([]byte(username+p), 8)
hash, err = bcrypt.GenerateFromPassword([]byte(p), 8)
if err != nil {
return mkerror("couldn't save password: " + err.Error())
}
Expand Down

0 comments on commit 2f12751

Please sign in to comment.