// Updates the user's password in the database. func ApiSettingsPassword(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { if !lib.IsLoggedIn(r) { SendJsonMessage(w, http.StatusUnauthorized, false, "Unauthorized.") return } // Get data from Request r.ParseForm() value := r.Form.Get("password") // Simple Validation if value == "" { SendJsonMessage(w, http.StatusBadRequest, false, "Unable to process your Request: Submit a valid value.") return } // Update Password admin := lib.Admin{} err := admin.ChangePassword(value) if err != nil { SendJsonMessage(w, http.StatusInternalServerError, false, "Unable to process your Request: "+err.Error()) return } SendJsonMessage(w, http.StatusOK, true, "") }