package com.cameleer.server.core.security;

import java.time.Instant;

/**
 * Represents a persisted user in the system.
 *
 * @param userId              unique identifier (e.g. OIDC {@code sub} or {@code user:<username>})
 * @param provider            authentication provider ({@code "local"}, {@code "oidc:<issuer-host>"})
 * @param email               user email (may be empty)
 * @param displayName         display name (may be empty)
 * @param createdAt           first creation timestamp
 * @param failedLoginAttempts number of consecutive failed login attempts
 * @param lockedUntil         account locked until this instant (null if not locked)
 * @param tokenRevokedBefore  tokens issued before this instant are rejected (null if no revocation)
 */
public record UserInfo(
        String userId,
        String provider,
        String email,
        String displayName,
        Instant createdAt,
        int failedLoginAttempts,
        Instant lockedUntil,
        Instant tokenRevokedBefore
) {
    /**
     * Convenience constructor for backwards compatibility (new fields default to safe values).
     */
    public UserInfo(String userId, String provider, String email, String displayName, Instant createdAt) {
        this(userId, provider, email, displayName, createdAt, 0, null, null);
    }
}
