@@ -60,7 +60,7 @@ public function handle(UserRepo $userRepo): int
6060 if ($ initialAdminOnly ) {
6161 $ handled = $ this ->handleInitialAdminIfExists ($ userRepo , $ details , $ shouldGeneratePassword , $ adminRole );
6262 if ($ handled !== null ) {
63- return $ handled ? 0 : 1 ;
63+ return $ handled ;
6464 }
6565 }
6666
@@ -87,16 +87,16 @@ public function handle(UserRepo $userRepo): int
8787
8888 /**
8989 * Handle updates to the original admin account if it exists.
90- * Returns true if it's been successfully handled, false if unsuccessful, or null if not handled.
90+ * Returns an int return status if handled, otherwise returns null if not handled (new user to be created) .
9191 */
92- protected function handleInitialAdminIfExists (UserRepo $ userRepo , array $ data , bool $ generatePassword , Role $ adminRole ): bool |null
92+ protected function handleInitialAdminIfExists (UserRepo $ userRepo , array $ data , bool $ generatePassword , Role $ adminRole ): int |null
9393 {
9494 $ defaultAdmin =
$ userRepo->
getByEmail (
'[email protected] ' );
9595 if ($ defaultAdmin && $ defaultAdmin ->hasSystemRole ('admin ' )) {
9696 if ($ defaultAdmin ->email !== $ data ['email ' ] && $ userRepo ->getByEmail ($ data ['email ' ]) !== null ) {
9797 $ this ->error ("Could not create admin account. " );
9898 $ this ->error ("An account with the email address \"{$ data ['email ' ]}\" already exists. " );
99- return false ;
99+ return 1 ;
100100 }
101101
102102 $ userRepo ->updateWithoutActivity ($ defaultAdmin , $ data , true );
@@ -106,10 +106,10 @@ protected function handleInitialAdminIfExists(UserRepo $userRepo, array $data, b
106106 $ this ->info ("The default admin user has been updated with the provided details! " );
107107 }
108108
109- return true ;
109+ return 0 ;
110110 } else if ($ adminRole ->users ()->count () > 0 ) {
111111 $ this ->warn ('Non-default admin user already exists. Skipping creation of new admin user. ' );
112- return true ;
112+ return 2 ;
113113 }
114114
115115 return null ;
0 commit comments