From d60aa722c007a0d10bd02c5ae744926a145f312f Mon Sep 17 00:00:00 2001 From: Quentin de Quelen Date: Thu, 21 Nov 2019 11:38:21 +0100 Subject: [PATCH] Allow to update `expireAt` and `revoked` on token --- meilidb-http/src/routes/key.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/meilidb-http/src/routes/key.rs b/meilidb-http/src/routes/key.rs index cdefc39ba..94b6ba2fa 100644 --- a/meilidb-http/src/routes/key.rs +++ b/meilidb-http/src/routes/key.rs @@ -117,6 +117,8 @@ pub struct UpdatedRequest { description: Option, acl: Option>, indexes: Option>, + expires_at: Option>, + revoked: Option, } pub async fn update(mut ctx: Context) -> SResult { @@ -154,6 +156,14 @@ pub async fn update(mut ctx: Context) -> SResult { token_config.indexes = indexes; } + if let Some(expires_at) = data.expires_at { + token_config.expires_at = expires_at; + } + + if let Some(revoked) = data.revoked { + token_config.revoked = revoked; + } + token_config.updated_at = Utc::now(); common_store @@ -163,7 +173,7 @@ pub async fn update(mut ctx: Context) -> SResult { writer.commit().map_err(ResponseError::internal)?; Ok(tide::response::json(token_config) - .with_status(StatusCode::ACCEPTED) + .with_status(StatusCode::OK) .into_response()) } @@ -185,5 +195,5 @@ pub async fn delete(ctx: Context) -> SResult { writer.commit().map_err(ResponseError::internal)?; - Ok(StatusCode::ACCEPTED) + Ok(StatusCode::NO_CONTENT) }