MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / get_user

Method get_user

chirpstack/src/api/tenant.rs:371–422  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::GetTenantUserRequest>,
    )

Source from the content-addressed store, hash-verified

369 }
370
371 async fn get_user(
372 &self,
373 request: Request<api::GetTenantUserRequest>,
374 ) -> Result<Response<api::GetTenantUserResponse>, Status> {
375 let req = request.get_ref();
376 let tenant_id = Uuid::from_str(&req.tenant_id).map_err(|e| e.status())?;
377 let user_id = Uuid::from_str(&req.user_id).map_err(|e| e.status())?;
378
379 self.validator
380 .validate(
381 request.extensions(),
382 validator::ValidateTenantUserAccess::new(validator::Flag::Read, tenant_id, user_id),
383 )
384 .await?;
385
386 let u = user::get(&user_id).await.map_err(|e| e.status())?;
387 let (tu, dps, apps) = tenant::get_user(&tenant_id, &user_id)
388 .await
389 .map_err(|e| e.status())?;
390
391 let mut resp = Response::new(api::GetTenantUserResponse {
392 tenant_user: Some(api::TenantUser {
393 tenant_id: tenant_id.to_string(),
394 user_id: tu.user_id.to_string(),
395 email: u.email.clone(),
396 is_admin: tu.is_admin,
397 is_device_admin: tu.is_device_admin,
398 is_gateway_admin: tu.is_gateway_admin,
399 device_profiles: dps
400 .iter()
401 .map(|dp| api::TenantUserDeviceProfile {
402 device_profile_id: dp.device_profile_id.to_string(),
403 })
404 .collect(),
405 applications: apps
406 .iter()
407 .map(|a| api::TenantUserApplication {
408 application_id: a.application_id.to_string(),
409 is_read_only: a.is_read_only,
410 })
411 .collect(),
412 }),
413 created_at: Some(helpers::datetime_to_prost_timestamp(&tu.created_at)),
414 updated_at: Some(helpers::datetime_to_prost_timestamp(&tu.updated_at)),
415 });
416 resp.metadata_mut()
417 .insert("x-log-tenant_id", req.tenant_id.parse().unwrap());
418 resp.metadata_mut()
419 .insert("x-log-user_id", req.user_id.parse().unwrap());
420
421 Ok(resp)
422 }
423
424 async fn update_user(
425 &self,

Callers

nothing calls this directly

Calls 9

statusMethod · 0.80
to_stringMethod · 0.80
iterMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
get_userFunction · 0.70
getFunction · 0.50
validateMethod · 0.45

Tested by

no test coverage detected