Add new error when using /keys without masterkey set

This commit is contained in:
vishalsodani 2022-10-18 10:48:45 +05:30
parent 96acbf815d
commit 1cf6efa740
3 changed files with 8 additions and 1 deletions

View file

@ -9,6 +9,8 @@ pub enum AuthenticationError {
// Triggered on configuration error.
#[error("An internal error has occurred. `Irretrievable state`.")]
IrretrievableState,
#[error("Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.")]
MissingMasterKey,
}
impl ErrorCode for AuthenticationError {
@ -17,6 +19,7 @@ impl ErrorCode for AuthenticationError {
AuthenticationError::MissingAuthorizationHeader => Code::MissingAuthorizationHeader,
AuthenticationError::InvalidToken => Code::InvalidToken,
AuthenticationError::IrretrievableState => Code::Internal,
AuthenticationError::MissingMasterKey => Code::MissingMasterKey,
}
}
}

View file

@ -57,7 +57,7 @@ impl<P, D> GuardedData<P, D> {
}),
None => Err(AuthenticationError::IrretrievableState.into()),
},
None => Err(AuthenticationError::MissingAuthorizationHeader.into()),
None => Err(AuthenticationError::MissingMasterKey.into()),
}
}