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:
@@ -350,8 +350,15 @@ func (r *tenantRepository) CreateTenantLocation(data models.Tenantlocations) err
|
|||||||
var user models.Tenantuser
|
var user models.Tenantuser
|
||||||
tx := r.db.Begin()
|
tx := r.db.Begin()
|
||||||
|
|
||||||
// Set status BEFORE insert
|
// Default to Active if the caller didn't specify — matches
|
||||||
data.Status = "InActive"
|
// 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
|
// Step 1: Insert into tenantlocations
|
||||||
if err := tx.Create(&data).Error; err != nil {
|
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.Locationid = data.Locationid
|
||||||
user.Applocationid = data.Applocationid
|
user.Applocationid = data.Applocationid
|
||||||
user.Configid = 1
|
user.Configid = 1
|
||||||
user.Status = "InActive"
|
user.Status = data.Status
|
||||||
user.Roleid = 0
|
user.Roleid = 0
|
||||||
user.Authmode = 0
|
user.Authmode = 0
|
||||||
user.Password = ""
|
user.Password = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user