Skip to main content

tuitbot_core/auth/
error.rs

1//! Authentication error types.
2
3/// Errors from authentication operations.
4#[derive(Debug, thiserror::Error)]
5pub enum AuthError {
6    /// The passphrase provided does not match the stored hash.
7    #[error("invalid passphrase")]
8    InvalidPassphrase,
9
10    /// The session token is expired or not found.
11    #[error("session expired or not found")]
12    SessionExpired,
13
14    /// Too many login attempts from this source.
15    #[error("rate limited: too many login attempts")]
16    RateLimited,
17
18    /// Passphrase hash file could not be read or written.
19    #[error("passphrase storage error: {message}")]
20    Storage { message: String },
21
22    /// Database error during session operations.
23    #[error("session database error: {source}")]
24    Database {
25        #[source]
26        source: sqlx::Error,
27    },
28
29    /// Bcrypt hashing failed.
30    #[error("hashing error: {message}")]
31    HashError { message: String },
32
33    /// Attempted to claim an instance that already has a passphrase.
34    #[error("instance already claimed")]
35    AlreadyClaimed,
36}