fix the patch of description and name for the api-key

This commit is contained in:
Tamo 2023-01-18 19:07:26 +01:00
parent 5dcb920fb4
commit d0988e115f
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
3 changed files with 16 additions and 8 deletions

View file

@ -8,6 +8,7 @@ use std::sync::Arc;
use error::{AuthControllerError, Result};
use meilisearch_types::keys::{Action, CreateApiKey, Key, PatchApiKey};
use meilisearch_types::milli::update::Setting;
use meilisearch_types::star_or::StarOr;
use serde::{Deserialize, Serialize};
pub use store::open_auth_store_env;
@ -41,8 +42,14 @@ impl AuthController {
pub fn update_key(&self, uid: Uuid, patch: PatchApiKey) -> Result<Key> {
let mut key = self.get_key(uid)?;
key.description = patch.description;
key.name = patch.name;
match patch.description {
Setting::NotSet => (),
description => key.description = description.set(),
};
match patch.name {
Setting::NotSet => (),
name => key.name = name.set(),
};
key.updated_at = OffsetDateTime::now_utc();
self.store.put_api_key(key)
}