Ejemplo n.º 1
0
func DeleteUser(userData database.UserData, userId string, password string) int {
	if len(userId) > 0 && len(password) > 0 {
		passwordHash, _ := userData.GetUser(userId)
		if passwordHash == nil {
			log.Warning("User not found, cannot delete: %s", userId)
			return http.StatusNotFound
		} else {
			if CompareHashAndPassword(passwordHash, password) == nil {
				userData.DeleteUser(userId)
				return http.StatusOK
			} else {
				return http.StatusBadRequest
			}

		}
	} else {
		log.Debug("Unable to delete user, username or password missing")
		return http.StatusBadRequest
	}
}