diff --git a/server/src/Mail/CustomerCredentialsMail.php b/server/src/Mail/CustomerCredentialsMail.php index af197524e..331fd564f 100644 --- a/server/src/Mail/CustomerCredentialsMail.php +++ b/server/src/Mail/CustomerCredentialsMail.php @@ -73,8 +73,10 @@ public function content(): Content private function getCustomerPortalAccessUrl(): string { $customerPortalConfig = Setting::lookupForCompany($this->customer->company_uuid, 'customer-portal-config'); - $accessUrlSlug = data_get($customerPortalConfig, 'accessUrlSlug', 'customer-portal'); + $accessUrlSlug = data_get($customerPortalConfig, 'accessUrlSlug'); - return Utils::consoleUrl($accessUrlSlug ?: 'customer-portal'); + // The portal resolves a company's access slug under /customer-access/{slug}; + // without one, send the customer to the portal's own sign-in route. + return Utils::consoleUrl($accessUrlSlug ? 'customer-access/' . $accessUrlSlug : 'customer-portal'); } } diff --git a/server/tests/NotificationAndMailContractsTest.php b/server/tests/NotificationAndMailContractsTest.php index 8539b5620..0e3e01016 100644 --- a/server/tests/NotificationAndMailContractsTest.php +++ b/server/tests/NotificationAndMailContractsTest.php @@ -704,5 +704,5 @@ public function track(Order $order, mixed $options): array $content = fleetOpsNotificationWithEnvironment(fn () => (new CustomerCredentialsMail('plain-secret', $customer))->content()); - expect($content->with['customerPortalUrl'])->toBe('https://console.fleetbase.test/acme-portal'); + expect($content->with['customerPortalUrl'])->toBe('https://console.fleetbase.test/customer-access/acme-portal'); })->with([null, 'other-company']);