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:
@@ -547,6 +547,11 @@ func (r *tenantRepository) CreateTenantUser(data models.Tenants) (bool, error) {
|
|||||||
user.Tenantid = data.Tenantid
|
user.Tenantid = data.Tenantid
|
||||||
user.Locationid = data.Tenantlocations.Locationid
|
user.Locationid = data.Tenantlocations.Locationid
|
||||||
user.Roleid = 1
|
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 {
|
if err := tx.Table("app_users").Create(&user).Error; err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
|||||||
Reference in New Issue
Block a user