Last active
November 28, 2016 23:24
-
-
Save ScullWM/176c434d3d11bb7eb64b5f618d478eaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func identifyUserFromForm(r *http.Request) User { | |
err := r.ParseForm() | |
email := r.Form.Get("email") | |
password := r.Form.Get("password") | |
du := User{} | |
u, err := du.FindOneUserByEmail(email) | |
if err != nil { | |
log.Fatal(err) | |
} else { | |
passwordPlainText := []byte(fmt.Sprintf("%s%s", u.Password_salt, password)) | |
err = bcrypt.CompareHashAndPassword([]byte(u.Password_hash), []byte(passwordPlainText)) | |
if err == nil { | |
log.Printf("user %s auth ok\n", u.Email) | |
return u | |
} | |
} | |
return du | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment