pub async fn authorize(
    conn: &mut PgConnection,
    action: Action,
    user_id: Option<Uuid>,
    resource: Resource
) -> Result<AuthorizationToken, ControllerError>
Expand description

The authorization token is the only way to return a controller result, and should only be used in controller functions that return a response to the user.

let token = authorize(&mut conn, Act::Edit, Some(user.id), Res::Page(*page_id)).await?;

token.authorized_ok(web::Json(cms_page_info))