no edit of oidc users, minimum hostname length (#2393)
* return an error when renaming users from OIDC * set minimum hostname length of 2
This commit is contained in:
parent
9bd143852f
commit
1c7f3bc440
3 changed files with 15 additions and 0 deletions
|
@ -81,6 +81,8 @@ func (hsdb *HSDatabase) RenameUser(uid types.UserID, newName string) error {
|
|||
})
|
||||
}
|
||||
|
||||
var ErrCannotChangeOIDCUser = errors.New("cannot edit OIDC user")
|
||||
|
||||
// RenameUser renames a User. Returns error if the User does
|
||||
// not exist or if another User exists with the new name.
|
||||
func RenameUser(tx *gorm.DB, uid types.UserID, newName string) error {
|
||||
|
@ -94,6 +96,10 @@ func RenameUser(tx *gorm.DB, uid types.UserID, newName string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if oldUser.Provider == util.RegisterMethodOIDC {
|
||||
return ErrCannotChangeOIDCUser
|
||||
}
|
||||
|
||||
oldUser.Name = newName
|
||||
|
||||
if err := tx.Save(&oldUser).Error; err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue