1
0
Fork 0

Add error handling for db lookup

master
Dario Ernst 8 years ago
parent ee289476df
commit a22cfe992f

@ -54,6 +54,10 @@ func getToken(w http.ResponseWriter, r *http.Request) error {
log.Println("getToken got name:", userInput.Name, "pass:", userInput.Pass)
db.First(&userRecord)
if db.Error != nil {
log.Println("db finding user had error",err)
return ehttp.NewErrorf(http.StatusInternalServerError, "database lookup error")
}
if userRecord.Name == userInput.Name && userRecord.Pass == userInput.Pass {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{

Loading…
Cancel
Save