IAM-08: benutzerprofil-login-oberflaeche (login+2fa/passwort-reset/profil-backend-handler + web/account next.js-frontend auf shl-01)
This commit is contained in:
@@ -126,6 +126,26 @@ type AuthCredentials struct {
|
||||
PasswordHash string
|
||||
}
|
||||
|
||||
// GetByIDForAuth liefert Benutzer + Passwort-Hash zu einer User-ID — fuer
|
||||
// IAM-08 (Passwortaenderung: die bestehende Session liefert die ID, nicht
|
||||
// die E-Mail-Adresse, gleiches Prinzip wie GetByEmailForAuth).
|
||||
func (s *TenantUserStore) GetByIDForAuth(ctx context.Context, id string) (AuthCredentials, error) {
|
||||
var c AuthCredentials
|
||||
row := s.pool.QueryRow(ctx, `
|
||||
SELECT id, email, name, status, created_at, updated_at, password_hash
|
||||
FROM users WHERE id = $1
|
||||
`, id)
|
||||
|
||||
if err := row.Scan(&c.User.ID, &c.User.Email, &c.User.Name, &c.User.Status,
|
||||
&c.User.CreatedAt, &c.User.UpdatedAt, &c.PasswordHash); err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return AuthCredentials{}, ErrNotFound
|
||||
}
|
||||
return AuthCredentials{}, fmt.Errorf("anmeldedaten lesen: %w", err)
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// GetByEmailForAuth liefert Benutzer + Passwort-Hash zu einer E-Mail-Adresse
|
||||
// aus GENAU DIESER Tenant-Datenbank — der Tenant-Scope ergibt sich damit
|
||||
// zwingend aus dem verwendeten Pool, es gibt keine Moeglichkeit, versehentlich
|
||||
|
||||
Reference in New Issue
Block a user