Admin can now change the user name of a user account. Closes issue #2.
This commit is contained in:
@@ -93,6 +93,7 @@ const (
|
||||
AuditAdminChangeUserAccount = 111
|
||||
AuditAdminSetAccountSecurity = 112
|
||||
AuditAdminLockUnlockAccount = 113
|
||||
AuditAdminSetUserName = 114
|
||||
AuditCommunityCreate = 201
|
||||
AuditCommunitySetMembership = 202
|
||||
AuditCommunityContactInfo = 203
|
||||
|
||||
@@ -44,6 +44,8 @@ auditReference:
|
||||
text: "Admin Set Account Security"
|
||||
- code: 113
|
||||
text: "Admin Lock/Unlock Account"
|
||||
- code: 114
|
||||
text: "Admin Set User Name"
|
||||
- code: 201
|
||||
text: "Create New Community"
|
||||
- code: 202
|
||||
|
||||
@@ -381,6 +381,18 @@ func (u *User) Prefs(ctx context.Context) (*UserPrefs, error) {
|
||||
return u.prefs, nil
|
||||
}
|
||||
|
||||
func (u *User) SetUsername(ctx context.Context, username string, setter *User, ipaddr string) error {
|
||||
u.Mutex.Lock()
|
||||
_, err := amdb.ExecContext(ctx, "UPDATE users SET username = ? WHERE uid = ?", username, u.Uid)
|
||||
u.Mutex.Unlock()
|
||||
if err == nil {
|
||||
u.Username = username
|
||||
AmStoreAudit(AmNewAudit(AuditAdminSetUserName, setter.Uid, ipaddr, fmt.Sprintf("uid=%d", u.Uid),
|
||||
fmt.Sprintf("newname=%s", username)))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
/* SetProfileData sets the "profile" variables for this user.
|
||||
* Parameters:
|
||||
* ctx - Standard Go context value.
|
||||
|
||||
Reference in New Issue
Block a user