From e48fb4cf573bfe4accc46c0cf3431efe4270f684 Mon Sep 17 00:00:00 2001 From: Suriya Date: Tue, 21 Jul 2026 17:13:58 +0530 Subject: [PATCH] Fix tenant onboarding creating admin users with configid=0 CreateTenantUser copied the tenant form's fields onto the new app_users row via copier.Copy, but the onboarding form never sends a configid, so it defaulted to 0. AppLogin's GetUserByAuthname always queries configid=1 for the web login, so any tenant onboarded through this path was permanently unable to log in by email ("Email not found") no matter what was typed. Set it explicitly, same as roleid. Co-Authored-By: Claude Sonnet 5 --- repositories/tenantRepository.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/repositories/tenantRepository.go b/repositories/tenantRepository.go index 1e9405e..72e44b9 100644 --- a/repositories/tenantRepository.go +++ b/repositories/tenantRepository.go @@ -547,6 +547,11 @@ func (r *tenantRepository) CreateTenantUser(data models.Tenants) (bool, error) { user.Tenantid = data.Tenantid user.Locationid = data.Tenantlocations.Locationid user.Roleid = 1 + // The onboarding form never sends a tenant configid, so copier.Copy left + // this at zero — AppLogin's GetUserByAuthname always queries configid=1 + // for the web login, so a zero here makes the account permanently + // unfindable by email no matter what's typed. + user.Configid = 1 if err := tx.Table("app_users").Create(&user).Error; err != nil { tx.Rollback()