package postgres import ( "backend/internal/adapter/repository/postgres/queries" "context" "crypto/sha256" "encoding/binary" "errors" "github.com/google/uuid" "github.com/jackc/pgx/v5" ) func (s *Store) AllowLogin(ctx context.Context, name string) (bool, error) { hash := sha256.Sum256([]byte(name)) bucket := int16(binary.BigEndian.Uint16(hash[:2]) % 4096) _, e := s.q.AllowLogin(ctx, bucket) if errors.Is(e, pgx.ErrNoRows) { return false, nil } return e == nil, mapErr(e) } func (s *Store) RehashPassword(ctx context.Context, id uuid.UUID, previous, replacement string) (bool, error) { _, e := s.q.RehashPassword(ctx, queries.RehashPasswordParams{UserID: id, Previous: previous, Replacement: replacement}) if errors.Is(e, pgx.ErrNoRows) { return false, nil } return e == nil, mapErr(e) }