package com.cameleer.server.core.security;

import java.time.Instant;
import java.util.List;
import java.util.Optional;

/**
 * Persistence interface for user management.
 */
public interface UserRepository {

    Optional<UserInfo> findById(String userId);

    List<UserInfo> findAll();

    void upsert(UserInfo user);

    void delete(String userId);

    void setPassword(String userId, String passwordHash);

    Optional<String> getPasswordHash(String userId);

    /** Increment failed login attempts; lock the account when >= 5 failures. */
    void recordFailedLogin(String userId);

    /** Reset failed login counter (call on successful login). */
    void clearFailedLogins(String userId);

    /** Check whether the account is currently locked. */
    boolean isLocked(String userId);

    /** Mark all tokens issued before {@code timestamp} as revoked for the given user. */
    void revokeTokensBefore(String userId, Instant timestamp);

    /** Total user count, used for {@code max_users} license cap enforcement. */
    long count();
}
