1use thiserror::Error;
2
3#[derive(Debug, Error, Clone, PartialEq, Eq)]
4pub enum OAuthError {
5 #[error("unknown provider: {provider}")]
6 ProviderNotFound { provider: String },
7
8 #[error("unsupported provider: {provider}")]
9 UnsupportedProvider { provider: String },
10
11 #[error("oauth provider misconfigured: {message}")]
12 Misconfigured { message: String },
13
14 #[error("oauth state invalid or expired")]
15 InvalidState,
16
17 #[error("oauth token exchange failed")]
18 ExchangeFailed,
19
20 #[error("oauth userinfo request failed")]
21 UserInfoFailed,
22
23 #[error("oauth userinfo payload invalid")]
24 UserInfoMalformed,
25
26 #[error("oauth provider did not return an access token")]
27 MissingAccessToken,
28
29 #[error("oauth provider did not provide a usable email")]
30 MissingEmail,
31
32 #[error("account linking by email is disabled")]
33 LinkingDisabled,
34}
35
36#[derive(Debug, Error)]
38pub enum AuthError {
39 #[error("invalid credentials")]
40 InvalidCredentials,
41
42 #[error("email already in use")]
43 EmailTaken,
44
45 #[error("user not found")]
46 UserNotFound,
47
48 #[error("session not found or expired")]
49 SessionNotFound,
50
51 #[error("token invalid or expired")]
52 InvalidToken,
53
54 #[error("email not verified")]
55 EmailNotVerified,
56
57 #[error("password must be at least {0} characters")]
58 WeakPassword(usize),
59
60 #[error("hash error: {0}")]
61 Hash(String),
62
63 #[error("store error: {0}")]
64 Store(String),
65
66 #[error("internal error: {0}")]
67 Internal(String),
68
69 #[error("oauth error: {0}")]
70 OAuth(#[from] OAuthError),
71}