Can get a single API token
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2024-04-09 19:04:49 +02:00
parent f56e9c14b2
commit 0c5a232a25
4 changed files with 30 additions and 6 deletions

View File

@ -1,7 +1,7 @@
//! # API tokens management
use crate::api_tokens;
use crate::api_tokens::NewToken;
use crate::api_tokens::{NewToken, TokenID};
use crate::controllers::api_tokens_controller::rest_token::RestToken;
use crate::controllers::HttpResult;
use crate::utils::jwt_utils::TokenPrivKey;
@ -58,3 +58,15 @@ pub async fn list() -> HttpResult {
Ok(HttpResponse::Ok().json(list))
}
#[derive(serde::Deserialize)]
pub struct TokenIDInPath {
uid: TokenID,
}
/// Get the information about a single token
pub async fn get_single(path: web::Path<TokenIDInPath>) -> HttpResult {
let token = api_tokens::get_single(path.uid).await?;
Ok(HttpResponse::Ok().json(RestToken::new(token)))
}