//! Authentication error types

use thiserror::Error;

/// Authentication errors
#[derive(Debug, Error)]
pub enum AuthError {
    /// Invalid credentials
    #[error("Invalid credentials")]
    InvalidCredentials,

    /// Session not found or invalid
    #[error("Invalid or expired session")]
    InvalidSession,

    /// User not found
    #[error("User not found")]
    UserNotFound,

    /// Session expired
    #[error("Session has expired")]
    SessionExpired,

    /// Database error
    #[error("Database error: {0}")]
    Database(String),

    /// Password hashing error
    #[error("Password hashing error: {0}")]
    PasswordHash(String),

    /// Internal error
    #[error("Internal error: {0}")]
    Internal(String),
}

impl From<bcrypt::BcryptError> for AuthError {
    fn from(err: bcrypt::BcryptError) -> Self {
        AuthError::PasswordHash(err.to_string())
    }
}

/// Result type for authentication operations
pub type AuthResult<T> = Result<T, AuthError>;
