mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-11 15:27:37 +00:00
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:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user