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 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-07-21 17:13:58 +05:30
parent 9258ce592c
commit e48fb4cf57

View File

@@ -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()