pub struct RequireRole<A: AuthInstance, R>(/* private fields */);Expand description
The signed-in session of a user who holds role R. Rejects with 401 UNAUTHORIZED
without a session and 403 FORBIDDEN without the role. A user holds every role in
their comma-separated user.role (the default role while it is empty); admins hold every
configured admin role, so RequireRole<A, role::Admin> also lets admin_user_ids in.
ⓘ
async fn dashboard(admin: RequireRole<AppAuth, role::Admin>) -> String {
format!("hello {}", admin.user.email)
}Derefs to the Session.
Implementations§
Source§impl<A: AuthInstance, R> RequireRole<A, R>
impl<A: AuthInstance, R> RequireRole<A, R>
Sourcepub fn into_session(self) -> Session<A>
pub fn into_session(self) -> Session<A>
The session.
Methods from Deref<Target = SessionData<<A as AuthInstance>::UserFields, <A as AuthInstance>::Plugins>>§
Sourcepub fn session_plugin<Pl, I>(&self) -> &<Pl as Plugin>::SessionFields
pub fn session_plugin<Pl, I>(&self) -> &<Pl as Plugin>::SessionFields
Columns a registered plugin added to session.
pub fn view(&self) -> &SessionView
Trait Implementations§
Source§impl<A: AuthInstance, R> Clone for RequireRole<A, R>
impl<A: AuthInstance, R> Clone for RequireRole<A, R>
Source§impl<A: AuthInstance, R> Deref for RequireRole<A, R>
impl<A: AuthInstance, R> Deref for RequireRole<A, R>
Source§impl<A, R, S> FromRequestParts<S> for RequireRole<A, R>
impl<A, R, S> FromRequestParts<S> for RequireRole<A, R>
Auto Trait Implementations§
impl<A, R> Forget for RequireRole<A, R>
impl<A, R> Freeze for RequireRole<A, R>
impl<A, R> Move for RequireRole<A, R>
impl<A, R> RefUnwindSafe for RequireRole<A, R>
impl<A, R> Send for RequireRole<A, R>
impl<A, R> Sync for RequireRole<A, R>
impl<A, R> Unpin for RequireRole<A, R>
impl<A, R> UnsafeUnpin for RequireRole<A, R>
impl<A, R> UnwindSafe for RequireRole<A, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.