MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / Edit

Method Edit

model/user.go:361–389  ·  view source on GitHub ↗
(updatePassword bool)

Source from the content-addressed store, hash-verified

359}
360
361func (user *User) Edit(updatePassword bool) error {
362 var err error
363 if updatePassword {
364 user.Password, err = common.Password2Hash(user.Password)
365 if err != nil {
366 return err
367 }
368 }
369
370 newUser := *user
371 updates := map[string]interface{}{
372 "username": newUser.Username,
373 "display_name": newUser.DisplayName,
374 "group": newUser.Group,
375 "quota": newUser.Quota,
376 "remark": newUser.Remark,
377 }
378 if updatePassword {
379 updates["password"] = newUser.Password
380 }
381
382 DB.First(&user, user.Id)
383 if err = DB.Model(user).Updates(updates).Error; err != nil {
384 return err
385 }
386
387 // Update cache
388 return updateUserCache(*user)
389}
390
391func (user *User) Delete() error {
392 if user.Id == 0 {

Callers 1

UpdateUserFunction · 0.95

Calls 2

Password2HashFunction · 0.92
updateUserCacheFunction · 0.85

Tested by

no test coverage detected