mirror of
https://github.com/nikdoof/pocket-id.git
synced 2025-12-14 07:12:19 +00:00
fix: non LDAP users get created with a empty LDAP ID string
This commit is contained in:
@@ -62,7 +62,10 @@ func (s *UserGroupService) Create(input dto.UserGroupCreateDto) (group model.Use
|
||||
group = model.UserGroup{
|
||||
FriendlyName: input.FriendlyName,
|
||||
Name: input.Name,
|
||||
LdapID: &input.LdapID,
|
||||
}
|
||||
|
||||
if input.LdapID != "" {
|
||||
group.LdapID = &input.LdapID
|
||||
}
|
||||
|
||||
if err := s.db.Preload("Users").Create(&group).Error; err != nil {
|
||||
|
||||
@@ -66,8 +66,11 @@ func (s *UserService) CreateUser(input dto.UserCreateDto) (model.User, error) {
|
||||
Email: input.Email,
|
||||
Username: input.Username,
|
||||
IsAdmin: input.IsAdmin,
|
||||
LdapID: &input.LdapID,
|
||||
}
|
||||
if input.LdapID != "" {
|
||||
user.LdapID = &input.LdapID
|
||||
}
|
||||
|
||||
if err := s.db.Create(&user).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrDuplicatedKey) {
|
||||
return model.User{}, s.checkDuplicatedFields(user)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE users SET ldap_id = '' WHERE ldap_id IS NULL;
|
||||
UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE users SET ldap_id = null WHERE ldap_id = '';
|
||||
UPDATE user_groups SET ldap_id = null WHERE ldap_id = '';
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE users SET ldap_id = '' WHERE ldap_id IS NULL;
|
||||
UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE users SET ldap_id = null WHERE ldap_id = '';
|
||||
UPDATE user_groups SET ldap_id = null WHERE ldap_id = '';
|
||||
Reference in New Issue
Block a user