bug(auth): Make API keys accept Null descriptions

This commit is contained in:
ManyTheFish 2022-02-02 18:18:17 +01:00
parent 622c15e825
commit 3bee31e6c7
2 changed files with 43 additions and 7 deletions

View file

@ -20,13 +20,14 @@ pub struct Key {
impl Key {
pub fn create_from_value(value: Value) -> Result<Self> {
let description = value
.get("description")
.map(|des| {
let description = match value.get("description") {
Some(Value::Null) => None,
Some(des) => Some(
from_value(des.clone())
.map_err(|_| AuthControllerError::InvalidApiKeyDescription(des.clone()))
})
.transpose()?;
.map_err(|_| AuthControllerError::InvalidApiKeyDescription(des.clone()))?,
),
None => None,
};
let id = generate_id();