fix(tenancy): use is_production() for invitation URL instead of debug flag
All checks were successful
All checks were successful
Using debug flag for environment detection is unreliable — if left True in prod, links would point to localhost. Now uses the proper is_production() from environment module. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,9 +47,22 @@ function scanJobs() {
|
||||
}
|
||||
},
|
||||
|
||||
// Maps button job types to actual API route segments
|
||||
batchRoutes: {
|
||||
'http_check': 'http-check',
|
||||
'tech_scan': 'tech-scan',
|
||||
'performance_scan': 'performance',
|
||||
'score_compute': 'score-compute',
|
||||
},
|
||||
|
||||
async startBatchJob(jobType) {
|
||||
var route = this.batchRoutes[jobType];
|
||||
if (!route) {
|
||||
Utils.showToast('Unknown job type: ' + jobType, 'error');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await apiClient.post('/admin/prospecting/enrichment/' + jobType.replace('_', '-') + '/batch');
|
||||
await apiClient.post('/admin/prospecting/enrichment/' + route + '/batch');
|
||||
Utils.showToast(jobType.replace(/_/g, ' ') + ' batch started', 'success');
|
||||
setTimeout(() => this.loadJobs(), 2000);
|
||||
} catch (err) {
|
||||
|
||||
@@ -29,11 +29,6 @@
|
||||
<span x-html="$icon('chart-bar', 'w-4 h-4 mr-2')"></span>
|
||||
Performance Scan
|
||||
</button>
|
||||
<button type="button" @click="startBatchJob('contact_scrape')"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none">
|
||||
<span x-html="$icon('mail', 'w-4 h-4 mr-2')"></span>
|
||||
Contact Scrape
|
||||
</button>
|
||||
<button type="button" @click="startBatchJob('score_compute')"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-red-600 border border-transparent rounded-lg hover:bg-red-700 focus:outline-none">
|
||||
<span x-html="$icon('cursor-click', 'w-4 h-4 mr-2')"></span>
|
||||
|
||||
@@ -981,18 +981,17 @@ class StoreTeamService:
|
||||
):
|
||||
"""Send team invitation email."""
|
||||
from app.core.config import settings as app_settings
|
||||
from app.core.environment import is_production
|
||||
from app.modules.messaging.services.email_service import EmailService
|
||||
|
||||
# Build acceptance URL using store's subdomain or main domain
|
||||
store_subdomain = store.subdomain
|
||||
# Build acceptance URL
|
||||
# Prod: https://{subdomain}.{main_domain}/invitation/accept?token=...
|
||||
# Dev: http://localhost:8000/store/{store_code}/invitation/accept?token=...
|
||||
main_domain = app_settings.main_domain.rstrip("/")
|
||||
|
||||
if app_settings.debug or "localhost" in main_domain:
|
||||
# Dev: use localhost with store path
|
||||
base_url = f"http://localhost:8000/store/{store.store_code}"
|
||||
if is_production():
|
||||
base_url = f"https://{store.subdomain}.{main_domain}"
|
||||
else:
|
||||
# Prod: use store subdomain
|
||||
base_url = f"https://{store_subdomain}.{main_domain}"
|
||||
base_url = f"http://localhost:8000/store/{store.store_code}"
|
||||
|
||||
acceptance_link = f"{base_url}/invitation/accept?token={token}"
|
||||
|
||||
|
||||
@@ -207,16 +207,15 @@ class APIClient {
|
||||
/**
|
||||
* POST request
|
||||
*/
|
||||
async post(endpoint, data = {}) {
|
||||
async post(endpoint, data = null) {
|
||||
apiLog.debug('POST request data:', {
|
||||
hasData: !!data,
|
||||
dataKeys: Object.keys(data)
|
||||
dataKeys: data ? Object.keys(data) : []
|
||||
});
|
||||
|
||||
return this.request(endpoint, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
var opts = { method: 'POST' };
|
||||
if (data != null) opts.body = JSON.stringify(data);
|
||||
return this.request(endpoint, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user