update user
This commit is contained in:
		@@ -72,19 +72,20 @@ func UsersItemPatch(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
	form := utils.BodyRead(r)
 | 
						form := utils.BodyRead(r)
 | 
				
			||||||
	user := models.User{ID: utils.ParamInt(mux.Vars(r)["id"], 0)}
 | 
						user := models.User{ID: utils.ParamInt(mux.Vars(r)["id"], 0)}
 | 
				
			||||||
	configs.ORMDB().First(&user)
 | 
						configs.ORMDB().First(&user)
 | 
				
			||||||
	if name, ok := form["name"]; ok {
 | 
						if name, ok := form["name"].(string); ok {
 | 
				
			||||||
		user.Name = name.(string)
 | 
							user.Name = name
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if email, ok := form["email"]; ok {
 | 
						if email, ok := form["email"].(string); ok {
 | 
				
			||||||
		user.Email = email.(string)
 | 
							user.Email = email
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if password, ok := form["password"]; ok {
 | 
						if password, ok := form["password"].(string); ok {
 | 
				
			||||||
		user.Slat = uuid.New().String()
 | 
							user.Slat = uuid.New().String()
 | 
				
			||||||
		user.Password = fmt.Sprintf("%x", md5.Sum([]byte(password.(string)+user.Slat)))
 | 
							user.Password = fmt.Sprintf("%x", md5.Sum([]byte(password+user.Slat)))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if admin, ok := form["admin"]; ok {
 | 
						if admin, ok := form["admin"].(bool); ok {
 | 
				
			||||||
		user.Admin = admin.(bool)
 | 
							user.Admin = admin
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	configs.ORMDB().Save(&user)
 | 
						configs.ORMDB().Save(&user)
 | 
				
			||||||
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
 | 
						w.Header().Set("Content-Type", "application/json; charset=utf-8")
 | 
				
			||||||
	w.Write(utils.ToJSON(user))
 | 
						w.Write(utils.ToJSON(user))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user