Skip to content

Commit

Permalink
Merge pull request #1038 from amvanbaren/bugfix/unique-system-users
Browse files Browse the repository at this point in the history
Add system provider for users
  • Loading branch information
amvanbaren authored Nov 14, 2024
2 parents c123517 + 1a0609f commit 03d2710
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public void applicationStarted(ApplicationStartedEvent event) {
@Transactional
public UserData createExtensionControlUser() {
var userName = "ExtensionControlUser";
var user = repositories.findUserByLoginName(null, userName);
var user = repositories.findUserByLoginName("system", userName);
if(user == null) {
user = new UserData();
user.setProvider("system");
user.setLoginName(userName);
entityManager.persist(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public FixTargetPlatformsService(RepositoryService repositories, EntityManager e
@Transactional
public UserData getUser() {
var userName = "FixTargetPlatformMigration";
var user = repositories.findUserByLoginName(null, userName);
var user = repositories.findUserByLoginName("system", userName);
if(user == null) {
user = new UserData();
user.setProvider("system");
user.setLoginName(userName);
entityManager.persist(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,21 @@ public List<ExtensionVersion> getExtensionTargetVersions(String namespaceName, S

@Transactional
public UserData createMirrorUser() {
var user = repositories.findUserByLoginName(null, userName);
if(user == null) {
user = new UserData();
user.setLoginName(userName);
entityManager.persist(user);
var user = repositories.findUserByLoginName("system", userName);
if(user != null) {
return user;
}

user = repositories.findUserByLoginName(null, userName);
if(user != null) {
user.setProvider("system");
return user;
}

user = new UserData();
user.setProvider("system");
user.setLoginName(userName);
entityManager.persist(user);
return user;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE user_data SET provider = 'system' WHERE login_name IN ('ExtensionControlUser', 'FixTargetPlatformMigration');

0 comments on commit 03d2710

Please sign in to comment.