/// Check that a user is an admin.
Check that a user is an admin.
Check that a user is an admin .
fn admin_authorization(user_id: Uuid) -> LocalBoxFuture<'static, AuthorizationResult> {
    Box::pin(async move {
        // Then check that their role is admin.
        let role: UserRole = RoleLookup::get(user_id)
            .await?
            // The role should not be none, since the account needs to exist at this point.
            .expect("Viewer's account does not exist.");
        // Forbid access unless the user is an admin.
        if !role.is_admin() {
            Err(TelescopeError::Forbidden)
        } else {
            Ok(())
        }
    })
}
fn admin_authorization ( user_id : Uuid ) -> LocalBoxFuture < ' static , AuthorizationResult > { Box :: pin ( async move { // Then check that their role is admin. let role : UserRole = RoleLookup :: get ( user_id ) . await ? // The role should not be none, since the account needs to exist at this point. . expect ( " " ) ; // Forbid access unless the user is an admin. if ! role . is_admin ( ) { Err ( TelescopeError :: Forbidden ) } else { Ok ( ( ) ) } } ) }
Check that a user is an admin.
Check that a user is an admin .
user_id
Uuid