MCPcopy Create free account
hub / github.com/astercloud/aster / UpdateUser

Method UpdateUser

pkg/security/access_control.go:372–397  ·  view source on GitHub ↗

UpdateUser 更新用户

(user *User)

Source from the content-addressed store, hash-verified

370
371// UpdateUser 更新用户
372func (ac *AccessController) UpdateUser(user *User) error {
373 ac.mu.Lock()
374 defer ac.mu.Unlock()
375
376 existing, exists := ac.users[user.ID]
377 if !exists {
378 return fmt.Errorf("user %s not found", user.ID)
379 }
380
381 user.CreatedAt = existing.CreatedAt
382 user.UpdatedAt = time.Now()
383
384 ac.users[user.ID] = user
385
386 // 记录审计日志
387 if ac.config.EnableAudit && ac.auditLog != nil {
388 _ = ac.auditLog.LogEvent(AuditEvent{
389 Type: AuditTypeUserUpdated,
390 UserID: user.ID,
391 Timestamp: time.Now(),
392 Message: fmt.Sprintf("User %s (%s) updated", user.ID, user.Username),
393 })
394 }
395
396 return nil
397}
398
399// DeleteUser 删除用户
400func (ac *AccessController) DeleteUser(userID string) error {

Callers 1

Calls 1

LogEventMethod · 0.65

Tested by 1