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

Method delete

chirpstack/src/api/user.rs:155–185  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::DeleteUserRequest>,
    )

Source from the content-addressed store, hash-verified

153 }
154
155 async fn delete(
156 &self,
157 request: Request<api::DeleteUserRequest>,
158 ) -> Result<Response<()>, Status> {
159 let req = request.get_ref();
160 let user_id = Uuid::from_str(&req.id).map_err(|e| e.status())?;
161
162 self.validator
163 .validate(
164 request.extensions(),
165 validator::ValidateUserAccess::new(validator::Flag::Delete, user_id),
166 )
167 .await?;
168
169 let auth_id = request.extensions().get::<AuthID>().unwrap();
170 if let AuthID::User(id) = auth_id
171 && id == &user_id
172 {
173 return Err(Status::invalid_argument(
174 "you can not delete yourself from the user",
175 ));
176 }
177
178 user::delete(&user_id).await.map_err(|e| e.status())?;
179
180 let mut resp = Response::new(());
181 resp.metadata_mut()
182 .insert("x-log-user_id", req.id.parse().unwrap());
183
184 Ok(resp)
185 }
186
187 async fn list(
188 &self,

Callers 15

test_async_requestFunction · 0.45
test_sync_requestFunction · 0.45
test_log_fn_okFunction · 0.45
test_log_fn_errorFunction · 0.45
test_pilot_thingsFunction · 0.45
test_thingsboardFunction · 0.45
test_mydevicesFunction · 0.45
test_influxdbFunction · 0.45
test_blynkFunction · 0.45
test_httpFunction · 0.45
test_ifttt_no_prefixFunction · 0.45

Calls 5

statusMethod · 0.80
unwrapMethod · 0.80
insertMethod · 0.80
deleteFunction · 0.50
validateMethod · 0.45

Tested by 15

test_async_requestFunction · 0.36
test_sync_requestFunction · 0.36
test_log_fn_okFunction · 0.36
test_log_fn_errorFunction · 0.36
test_pilot_thingsFunction · 0.36
test_thingsboardFunction · 0.36
test_mydevicesFunction · 0.36
test_influxdbFunction · 0.36
test_blynkFunction · 0.36
test_httpFunction · 0.36
test_ifttt_no_prefixFunction · 0.36