Check if the master key is missing before returning an error

This commit is contained in:
ManyTheFish 2022-11-24 16:02:14 +01:00
parent cfa78418f2
commit 1eba5d45ea

View File

@ -31,11 +31,14 @@ impl<P, D> GuardedData<P, D> {
where where
P: Policy + 'static, P: Policy + 'static,
{ {
let missing_master_key = auth.get_master_key().is_none();
match Self::authenticate(auth, token, index).await? { match Self::authenticate(auth, token, index).await? {
Some(filters) => match data { Some(filters) => match data {
Some(data) => Ok(Self { data, filters, _marker: PhantomData }), Some(data) => Ok(Self { data, filters, _marker: PhantomData }),
None => Err(AuthenticationError::IrretrievableState.into()), None => Err(AuthenticationError::IrretrievableState.into()),
}, },
None if missing_master_key => Err(AuthenticationError::MissingMasterKey.into()),
None => Err(AuthenticationError::InvalidToken.into()), None => Err(AuthenticationError::InvalidToken.into()),
} }
} }