refactor: use helper function to scan user in GetUserByID

This commit is contained in:
juancwu 2026-05-06 00:38:33 +00:00
commit 418aeb5f6c

View file

@ -75,22 +75,14 @@ func (s *Store) CreateUser(ctx context.Context, u *store.User) error {
func (s *Store) GetUserByID(ctx context.Context, id string) (*store.User, error) {
row := s.db.QueryRowContext(ctx, s.q.GetUserByID, id)
var u store.User
err := row.Scan(
&u.ID, &u.Email, &u.EmailVerifiedAt,
&u.Username, &u.UsernameNormalized, &u.DisplayName, &u.ProfileImageURL,
&u.Status, &u.StatusReason,
&u.StatusChangedAt, &u.StatusExpiresAt,
&u.FailedLoginCount, &u.LastFailedLoginAt,
&u.CreatedAt, &u.UpdatedAt,
)
u, err := s.scanUser(row)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, fmt.Errorf("pase/sqlite: get user by id: %w", store.ErrUserNotFound)
}
return nil, fmt.Errorf("pase/sqlite: get user by id: %w", err)
}
return &u, nil
return u, nil
}
func (s *Store) GetUserByEmail(ctx context.Context, email string) (*store.User, error) {