headless_lms_server/controllers/main_frontend/
org.rs1use models::organizations::Organization;
4
5use crate::{domain::authorization::skip_authorize, prelude::*};
6
7#[instrument(skip(pool, file_store, app_conf))]
12async fn get_organization_by_slug(
13 pool: web::Data<PgPool>,
14 organization_slug: web::Path<String>,
15 file_store: web::Data<dyn FileStore>,
16 app_conf: web::Data<ApplicationConfiguration>,
17) -> ControllerResult<web::Json<Organization>> {
18 let mut conn = pool.acquire().await?;
19 let db_organization =
20 models::organizations::get_organization_by_slug(&mut conn, &organization_slug).await?;
21 let organization =
22 Organization::from_database_organization(db_organization, file_store.as_ref(), &app_conf);
23
24 let token = skip_authorize();
25 token.authorized_ok(web::Json(organization))
26}
27
28pub fn _add_routes(cfg: &mut ServiceConfig) {
36 cfg.route(
37 "/{organization_slug}",
38 web::get().to(get_organization_by_slug),
39 );
40}