diff --git a/api/portal/myBusinesses.cfm b/api/portal/myBusinesses.cfm index aa17c67..0f01d15 100644 --- a/api/portal/myBusinesses.cfm +++ b/api/portal/myBusinesses.cfm @@ -42,23 +42,20 @@ try { abort; } - // Get businesses for this user - // Users are linked to businesses via UserID field (owner) + // Get businesses for this user (owner only) q = queryExecute(" - SELECT - b.ID, - b.Name + SELECT b.BusinessID, b.BusinessName FROM Businesses b - WHERE b.UserID = :userID - ORDER BY b.Name + WHERE b.BusinessUserID = :userID + ORDER BY b.BusinessName ", { userID: userID }, { datasource: "payfrit" }); businesses = []; for (row in q) { arrayAppend(businesses, { - "BusinessID": row.ID, - "Name": row.Name + "BusinessID": row.BusinessID, + "Name": row.BusinessName }); } diff --git a/portal/login.html b/portal/login.html index cd0f531..3c27e00 100644 --- a/portal/login.html +++ b/portal/login.html @@ -342,7 +342,12 @@ this.showStep('business'); } } else { - errorEl.textContent = data.ERROR || data.MESSAGE || 'Invalid credentials'; + const friendlyErrors = { + 'bad_credentials': 'Incorrect email/phone or password. Please try again.', + 'not_found': 'No account found with that email or phone number.', + 'account_disabled': 'This account has been disabled. Please contact support.' + }; + errorEl.textContent = friendlyErrors[data.ERROR] || data.MESSAGE || 'Invalid credentials'; errorEl.classList.add('show'); } } catch (err) { @@ -407,7 +412,7 @@ this.businesses.forEach(biz => { const option = document.createElement('option'); option.value = biz.BusinessID; - option.textContent = biz.BusinessName; + option.textContent = biz.Name; select.appendChild(option); }); diff --git a/portal/portal.js b/portal/portal.js index a6b25c6..970d5e3 100644 --- a/portal/portal.js +++ b/portal/portal.js @@ -83,7 +83,7 @@ const Portal = { const data = await response.json(); if (data.OK && data.BUSINESSES) { - const hasAccess = data.BUSINESSES.some(b => b.ID === this.config.businessId); + const hasAccess = data.BUSINESSES.some(b => b.BusinessID === this.config.businessId); if (!hasAccess && data.BUSINESSES.length > 0) { // User doesn't have access to requested business, use their first business this.config.businessId = data.BUSINESSES[0].BusinessID;