#![allow(deprecated)]
pub use reinhardt_auth::{
AllowAny, AnonymousUser, AuthBackend, IsAdminUser, IsAuthenticated, IsAuthenticatedOrReadOnly,
Permission, SimpleUser, User,
};
#[cfg(feature = "jwt")]
pub use reinhardt_auth::{Claims, JwtAuth};
#[derive(Debug, Clone)]
pub enum AuthResult<U> {
Authenticated(U),
Anonymous,
Failed(String),
}
impl<U> AuthResult<U> {
pub fn is_authenticated(&self) -> bool {
matches!(self, AuthResult::Authenticated(_))
}
pub fn user(self) -> Option<U> {
match self {
AuthResult::Authenticated(user) => Some(user),
_ => None,
}
}
pub fn error(&self) -> Option<&str> {
match self {
AuthResult::Failed(msg) => Some(msg),
_ => None,
}
}
}