lemmy/crates/routes/src/lib.rs

25 lines
697 B
Rust
Raw Normal View History

use lemmy_api_common::{claims::Claims, context::LemmyContext, utils::check_user_valid};
use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::error::LemmyError;
2020-05-16 14:04:08 +00:00
pub mod feeds;
pub mod images;
2020-05-16 14:04:08 +00:00
pub mod nodeinfo;
pub mod webfinger;
#[tracing::instrument(skip_all)]
async fn local_user_view_from_jwt(
jwt: &str,
context: &LemmyContext,
) -> Result<LocalUserView, LemmyError> {
let local_user_id = Claims::validate(jwt, context).await?;
let local_user_view = LocalUserView::read(&mut context.pool(), local_user_id).await?;
check_user_valid(
local_user_view.person.banned,
local_user_view.person.ban_expires,
local_user_view.person.deleted,
)?;
Ok(local_user_view)
}