Add random password generation for new users

- Move GenerateRandomPassword to auth package for reuse
- Make password optional in user creation (generates 16-char if empty)
- Return generated password in response for user to copy
- Add Generate/Copy UI with show/hide toggle
This commit is contained in:
Christoph Haas 2026-03-29 14:52:59 +02:00
parent 7cdc561dcc
commit 8b2d2649ac
4 changed files with 80 additions and 20 deletions

View file

@ -25,7 +25,7 @@ func (d *DB) GetUserByEmail(ctx context.Context, email string) (imcdb.VirtualUse
}
func (d *DB) CreateUser(ctx context.Context, domainID uint32, email, passwordHash string, quota int64) error {
quotaNull := sql.NullInt64{Int64: quota, Valid: quota > 0}
quotaNull := sql.NullInt64{Int64: quota, Valid: true}
return d.Queries.CreateUser(ctx, imcdb.CreateUserParams{
DomainID: domainID,
Email: email,
@ -42,7 +42,7 @@ func (d *DB) UpdateUserPassword(ctx context.Context, id uint32, passwordHash str
}
func (d *DB) UpdateUserQuota(ctx context.Context, id uint32, quota int64) error {
quotaNull := sql.NullInt64{Int64: quota, Valid: quota > 0}
quotaNull := sql.NullInt64{Int64: quota, Valid: true}
return d.Queries.UpdateUserQuota(ctx, imcdb.UpdateUserQuotaParams{
Quota: quotaNull,
ID: id,