use thiserror::Error;
#[derive(Debug, Error)]
pub enum AuthError {
#[error("Invalid credentials")]
InvalidCredentials,
#[error("Invalid or expired session")]
InvalidSession,
#[error("User not found")]
UserNotFound,
#[error("Session has expired")]
SessionExpired,
#[error("Database error: {0}")]
Database(String),
#[error("Password hashing error: {0}")]
PasswordHash(String),
#[error("Internal error: {0}")]
Internal(String),
}
impl From<bcrypt::BcryptError> for AuthError {
fn from(err: bcrypt::BcryptError) -> Self {
AuthError::PasswordHash(err.to_string())
}
}
pub type AuthResult<T> = Result<T, AuthError>;