Esempio n. 1
0
func (lc *LoginController) PostLogin(w http.ResponseWriter, r *http.Request) {
	var um *models.User

	decoder := json.NewDecoder(r.Body)
	if err := decoder.Decode(&um); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	if !um.Authenticate(um) {
		http.Error(w, "Invalid username or password.", http.StatusUnauthorized)
		return
	}

}