Stop forcing new store outlets and their logins to InActive

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 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-07-21 18:01:15 +05:30
parent e48fb4cf57
commit 5bd1f52d41

View File

@@ -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 = ""