Collapse migrations, require email at registration
No deployed environments yet, so consolidate the entire migration history into a single Initial migration and tighten the schema accordingly. - User.Email is now non-nullable (required); the partial unique index used to tolerate legacy null emails is gone in favor of a plain unique index. - Both register paths require an email up front. Invite-path registrations must match the invited address (server ignores any mismatched client value); family-code registrations bind whatever the user supplies but stay unconfirmed (EmailConfirmedAt = null) since the family code does not prove email ownership. - Validation order in /register reworked: invite/family-code resolution runs before duplicate-name/email checks so a consumed token surfaces a clean "invitation invalid" error instead of getting masked by the duplicate-email response. - All 14 prior migrations replaced with a single Initial migration. - Test fixtures, builders, and unit tests updated to supply emails. - Login page register form now collects an email field; invite-bound registrations show the invited address as a read-only input. Local dev DBs need to be recreated (drop the yeschef-pgdata volume or the yeschef Postgres database). No production data exists yet.
This commit is contained in:
@@ -8,15 +8,22 @@ public sealed class UserBuilder
|
||||
{
|
||||
private string _name = $"user-{Guid.NewGuid():N}"[..16];
|
||||
private string _password = "correct-horse-battery-staple";
|
||||
private string? _email;
|
||||
|
||||
public UserBuilder Named(string name) { _name = name; return this; }
|
||||
public UserBuilder WithPassword(string password) { _password = password; return this; }
|
||||
public UserBuilder WithEmail(string email) { _email = email; return this; }
|
||||
|
||||
public string PlaintextPassword => _password;
|
||||
|
||||
public User Build()
|
||||
{
|
||||
var user = new User { Name = _name, PasswordHash = "" };
|
||||
var user = new User
|
||||
{
|
||||
Name = _name,
|
||||
PasswordHash = "",
|
||||
Email = _email ?? $"{_name}@example.test",
|
||||
};
|
||||
user.PasswordHash = new PasswordHasher<User>().HashPassword(user, _password);
|
||||
return user;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user