1#[derive(Debug, thiserror::Error)]
5pub enum AuthError {
6 #[error("auth: invalid credentials")]
8 InvalidCredentials,
9
10 #[error("auth: email already taken")]
12 EmailTaken,
13
14 #[error("auth: unauthorized")]
16 Unauthorized,
17
18 #[error("auth: invalid token")]
20 InvalidToken,
21
22 #[error("auth: jwt error: {0}")]
24 Jwt(String),
25
26 #[error("auth: oauth error: {0}")]
28 OAuth(String),
29
30 #[cfg(feature = "auth-2fa")]
32 #[error("auth: two-factor error: {0}")]
33 TwoFactor(String),
34
35 #[error("auth: config error: {0}")]
37 Config(String),
38
39 #[error("auth: unknown strategy: {0}")]
41 UnknownStrategy(String),
42
43 #[error("auth: internal error: {0}")]
45 Internal(String),
46}
47
48impl From<jsonwebtoken::errors::Error> for AuthError {
49 fn from(e: jsonwebtoken::errors::Error) -> Self {
50 AuthError::Jwt(e.to_string())
51 }
52}