From 5bd1f52d41eca7670b7d8b3b659cabc03de5e133 Mon Sep 17 00:00:00 2001 From: Suriya Date: Tue, 21 Jul 2026 18:01:15 +0530 Subject: [PATCH] Stop forcing new store outlets and their logins to InActive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CreateTenantLocation hardcoded the new location and its auto-spawned manager login to InActive regardless of what the caller sent (the frontend already sends Active). AppLogin checks account status before checking whether a password is set, so a new store's login could never reach the password-setup screen — permanently stuck on "Inactive Account. Contact admin." Co-Authored-By: Claude Sonnet 5 --- repositories/tenantRepository.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/repositories/tenantRepository.go b/repositories/tenantRepository.go index 72e44b9..5cf9cf0 100644 --- a/repositories/tenantRepository.go +++ b/repositories/tenantRepository.go @@ -350,8 +350,15 @@ func (r *tenantRepository) CreateTenantLocation(data models.Tenantlocations) err var user models.Tenantuser tx := r.db.Begin() - // Set status BEFORE insert - data.Status = "InActive" + // Default to Active if the caller didn't specify — matches + // tenantlocations' own gorm default and the primary-location behavior + // from tenant onboarding. Forcing InActive here used to also block the + // spawned manager login (AppLogin checks account status before it ever + // gets to the "no password set" branch), so a new store's login could + // never reach the password-setup screen. + if data.Status == "" { + data.Status = "Active" + } // Step 1: Insert into tenantlocations if err := tx.Create(&data).Error; err != nil { @@ -374,7 +381,7 @@ func (r *tenantRepository) CreateTenantLocation(data models.Tenantlocations) err user.Locationid = data.Locationid user.Applocationid = data.Applocationid user.Configid = 1 - user.Status = "InActive" + user.Status = data.Status user.Roleid = 0 user.Authmode = 0 user.Password = ""