mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
refactor code to avoid cloning
This commit is contained in:
parent
03ba830ab2
commit
89c40c83c3
@ -48,8 +48,7 @@ impl<P, D> GuardedData<P, D> {
|
|||||||
where
|
where
|
||||||
P: Policy + 'static,
|
P: Policy + 'static,
|
||||||
{
|
{
|
||||||
let auth_clone = auth.clone();
|
let missing_master_key = auth.get_master_key().is_none();
|
||||||
let master_key: Option<&String> = auth_clone.get_master_key();
|
|
||||||
|
|
||||||
match Self::authenticate(auth, String::new(), None).await? {
|
match Self::authenticate(auth, String::new(), None).await? {
|
||||||
Some(filters) => match data {
|
Some(filters) => match data {
|
||||||
@ -61,10 +60,10 @@ impl<P, D> GuardedData<P, D> {
|
|||||||
|
|
||||||
None => Err(AuthenticationError::IrretrievableState.into()),
|
None => Err(AuthenticationError::IrretrievableState.into()),
|
||||||
},
|
},
|
||||||
None => match master_key {
|
None if missing_master_key => {
|
||||||
Some(_) => Err(AuthenticationError::MissingAuthorizationHeader.into()),
|
Err(AuthenticationError::MissingMasterKey.into())
|
||||||
None => Err(AuthenticationError::MissingMasterKey.into()),
|
}
|
||||||
},
|
None => Err(AuthenticationError::MissingAuthorizationHeader.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user