mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-05 02:55:46 +01:00
Forward the key deletions to zookeeper
This commit is contained in:
parent
0cd81573b4
commit
a325ddfe6a
@ -175,8 +175,13 @@ impl AuthController {
|
|||||||
self.store.list_api_keys()
|
self.store.list_api_keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete_key(&self, uid: Uuid) -> Result<()> {
|
pub async fn delete_key(&self, uid: Uuid) -> Result<()> {
|
||||||
if self.store.delete_api_key(uid)? {
|
let store = self.store.clone();
|
||||||
|
let deleted = tokio::task::spawn_blocking(move || store.delete_api_key(uid)).await??;
|
||||||
|
if deleted {
|
||||||
|
if let Some(ref zk) = self.zk {
|
||||||
|
zk.delete(&format!("/auth/{}", uid), None).await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(AuthControllerError::ApiKeyNotFound(uid.to_string()))
|
Err(AuthControllerError::ApiKeyNotFound(uid.to_string()))
|
||||||
|
@ -118,13 +118,8 @@ pub async fn delete_api_key(
|
|||||||
path: web::Path<AuthParam>,
|
path: web::Path<AuthParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let key = path.into_inner().key;
|
let key = path.into_inner().key;
|
||||||
tokio::task::spawn_blocking(move || {
|
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.get_uid_from_encoded_key(&key))?;
|
||||||
let uid =
|
auth_controller.delete_key(uid).await?;
|
||||||
Uuid::parse_str(&key).or_else(|_| auth_controller.get_uid_from_encoded_key(&key))?;
|
|
||||||
auth_controller.delete_key(uid)
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.map_err(|e| ResponseError::from_msg(e.to_string(), Code::Internal))??;
|
|
||||||
|
|
||||||
Ok(HttpResponse::NoContent().finish())
|
Ok(HttpResponse::NoContent().finish())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user