23
23
import io .hyperfoil .tools .horreum .entity .user .UserInfo ;
24
24
import io .hyperfoil .tools .horreum .entity .user .UserRole ;
25
25
import io .hyperfoil .tools .horreum .svc .Roles ;
26
+ import io .hyperfoil .tools .horreum .svc .UserServiceImpl ;
26
27
import io .hyperfoil .tools .horreum .svc .user .UserBackEnd ;
27
28
import io .quarkus .logging .Log ;
28
29
import io .quarkus .runtime .LaunchMode ;
@@ -128,8 +129,6 @@ private void addTeamMembership(UserInfo userInfo, String teamName, TeamRole role
128
129
* Create an admin account if there are no accounts in the system.
129
130
* The account should be removed once other accounts are created.
130
131
*/
131
- @ WithRoles (extras = BOOTSTRAP_ACCOUNT )
132
- @ Transactional
133
132
public void checkBootstrapAccount () {
134
133
// checks the list of administrators. a user cannot remove himself nor create the bootstrap account (restricted namespace)
135
134
List <String > administrators = backend .get ().administrators ().stream ().map (userData -> userData .username ).toList ();
@@ -149,20 +148,17 @@ public void checkBootstrapAccount() {
149
148
backend .get ().updateTeamMembers ("dev-team" ,
150
149
Map .of (BOOTSTRAP_ACCOUNT , List .of (Roles .MANAGER , Roles .TESTER , Roles .UPLOADER , Roles .VIEWER )));
151
150
152
- // create db entry, if not existent, like in UserService.createLocalUser()
153
- UserInfo userInfo = UserInfo .<UserInfo > findByIdOptional (BOOTSTRAP_ACCOUNT ).orElse (new UserInfo (BOOTSTRAP_ACCOUNT ));
154
- userInfo .defaultTeam = "dev-team" ;
155
- userInfo .persist ();
151
+ UserServiceImpl .createLocalUser (BOOTSTRAP_ACCOUNT , "dev-team" );
156
152
157
153
Log .infov ("\n >>>\n >>> Created temporary account {0} with password {1}\n >>>" , BOOTSTRAP_ACCOUNT , user .password );
158
154
} else if (administrators .size () > 1 && administrators .contains (BOOTSTRAP_ACCOUNT )) {
159
155
Log .warnv ("The temporary account {0} can be removed" , BOOTSTRAP_ACCOUNT );
160
156
}
161
157
}
162
158
163
- public static String generateRandomPassword (int lenght ) {
164
- StringBuilder builder = new StringBuilder (lenght );
165
- new SecureRandom ().ints (lenght , 0 , RANDOM_PASSWORD_CHARS .length ).mapToObj (i -> RANDOM_PASSWORD_CHARS [i ])
159
+ public static String generateRandomPassword (int length ) {
160
+ StringBuilder builder = new StringBuilder (length );
161
+ new SecureRandom ().ints (length , 0 , RANDOM_PASSWORD_CHARS .length ).mapToObj (i -> RANDOM_PASSWORD_CHARS [i ])
166
162
.forEach (builder ::append );
167
163
return builder .toString ();
168
164
}
0 commit comments