33namespace ProcessMaker \Console \Commands ;
44
55use Illuminate \Console \Command ;
6+ use Illuminate \Contracts \Encryption \DecryptException ;
67use Illuminate \Support \Facades \Config ;
8+ use Illuminate \Support \Facades \Crypt ;
79use Illuminate \Support \Facades \File ;
810use Illuminate \Support \Facades \Log ;
911use ProcessMaker \Models \EnvironmentVariable ;
@@ -26,17 +28,6 @@ class TenantsVerify extends Command
2628 */
2729 protected $ description = 'Verify tenant configuration and storage paths ' ;
2830
29- /**
30- * Strip protocol from URL
31- *
32- * @param string $url
33- * @return string
34- */
35- private function stripProtocol (string $ url ): string
36- {
37- return preg_replace ('#^https?://# ' , '' , $ url );
38- }
39-
4031 /**
4132 * Execute the console command.
4233 *
@@ -49,13 +40,13 @@ public function handle()
4940 $ currentTenant = app ('currentTenant ' );
5041 }
5142
52- if (!$ currentTenant ) {
53- $ this ->error ('No current tenant found ' );
43+ if (config ( ' app.multitenancy ' ) && !$ currentTenant ) {
44+ $ this ->error ('Multitenancy enabled but current tenant found. ' );
5445
5546 return ;
5647 }
5748
58- $ this ->info ('Current Tenant ID: ' . $ currentTenant ->id );
49+ $ this ->info ('Current Tenant ID: ' . ( $ currentTenant? ->id ?? ' NONE ' ) );
5950
6051 $ paths = [
6152 ['Storage Path ' , storage_path ()],
@@ -88,14 +79,26 @@ public function handle()
8879 // Display configs in a nice table
8980 $ this ->table (['Config ' , 'Value ' ], $ configs );
9081
82+ $ env = EnvironmentVariable::first ();
83+ if (!$ env ) {
84+ $ decrypted = 'No environment variables found to test decryption ' ;
85+ }
86+ $ encryptedValue = $ env ->getAttributes ()['value ' ];
87+ try {
88+ Crypt::decryptString ($ encryptedValue );
89+ $ decrypted = 'OK ' ;
90+ } catch (DecryptException $ e ) {
91+ $ decrypted = 'FAILED! ' . $ e ->getMessage ();
92+ }
93+
9194 $ other = [
9295 ['Landlord Config Cache Path ' , base_path ('bootstrap/cache/config.php ' )],
9396 ['Landlord Config Is Cached ' , File::exists (base_path ('bootstrap/cache/config.php ' )) ? 'Yes ' : 'No ' ],
9497 ['Tenant Config Cache Path ' , app ()->getCachedConfigPath ()],
9598 ['Tenant Config Is Cached ' , File::exists (app ()->getCachedConfigPath ()) ? 'Yes ' : 'No ' ],
9699 ['First username (database check) ' , User::first ()->username ],
97- ['First environment variable (decrypted check) ' , substr (EnvironmentVariable:: first ()-> value , 0 , 15 )],
98- ['Original App URL (landlord) ' , $ currentTenant ->getOriginalValue ('APP_URL ' )],
100+ ['Decrypted check ' , substr ($ decrypted , 0 , 50 )],
101+ ['Original App URL (landlord) ' , $ currentTenant? ->getOriginalValue('APP_URL ' ) ?? config ( ' app.url ' )],
99102 ];
100103
101104 // Display other in a nice table
0 commit comments