Hi,
I just tried adding multi tenant to an existing project and found I could not logon using tenantsadmin. Then I tried a new project and have the same issue. This did not used not be an issue, has something changed in the recent releases?
No errors in the log...
Executed DbCommand (62ms) [Parameters=[@__normalizedUserName_0='?'], CommandType='Text', CommandTimeout='30']
SELECT a."Id", a."AccessFailedCount", a."ConcurrencyStamp", a."Email", a."EmailConfirmed", a."LockoutEnabled", a."LockoutEnd", a."NormalizedEmail", a."NormalizedUserName", a."PasswordHash", a."PhoneNumber", a."PhoneNumberConfirmed", a."SecurityStamp", a."TenantId", a."TwoFactorEnabled", a."UserName"
FROM "AspNetUsers" AS a
WHERE a."NormalizedUserName" = @__normalizedUserName_0
LIMIT 1
dotnet: info: Microsoft.AspNetCore.Mvc.Infrastructure.RedirectResultExecutor[1]
Executing RedirectResult, redirecting to /Login?error=Invalid user or password..
The database looks ok and the migration went ok...
There are no recent changes related to tenants, you can get any previous version to check it. The tenants admin user and password are seed using security migration and you can change it only from the profile page, not from database.
I understand the seed process and that you do not change passwords direct in the database. I do not understand why the tenantsadmin/tenantsadmin is showing as an incorrect password. I started with no aspnet or ef_migration tables in the database and a new blazor project and the identity migration seemed to work perfectly on starting the app. I just cannot logon as tenantsadmin. Any tips on how to diagnose?
Hi, @enchev I came back to this problem in another project using webassembly. It turns out that there is a bug in your code that creates the tenantsadmin user. The normalized value for the username should be uppercase whereas the generated code creates it in lowercase. FindByNameAsync looks up the normalized username and compares with an uppercsase normalized string. You should change the value in ApplicationIdentityDbContext to match the expected value.
UserName.ToUpper().Normalize()
I've not looked but assume the same for email.
I'm guessing I experience the issue because I'm running PostgreSQL on a Linux server which defaults to being case sensitive and a default SQL database would be case insensitive.
@enchev Your explicit lowercasing is the problem. FindByNameAsync expects an uppercase, normalized value in the database. It takes the user input and applies upper & normalize before comparing to the database value.
Bottom line is that uppercase TENANTSADMIN as NormalizedUserName fixed my problem.