Can delete API token from UI
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::auth_extractor::{AuthExtractor, AuthenticatedMethod};
|
||||
use crate::users::{APIToken, BaseAPIToken};
|
||||
use actix_web::HttpResponse;
|
||||
use crate::users::{APIToken, APITokenID, BaseAPIToken};
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
/// Create a new token
|
||||
pub async fn create(auth: AuthExtractor) -> HttpResult {
|
||||
@@ -34,3 +34,15 @@ pub async fn get_list(auth: AuthExtractor) -> HttpResult {
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct TokenIDInPath {
|
||||
id: APITokenID,
|
||||
}
|
||||
|
||||
/// Delete an API access token
|
||||
pub async fn delete(auth: AuthExtractor, path: web::Path<TokenIDInPath>) -> HttpResult {
|
||||
let token = APIToken::load(&auth.user.email, &path.id).await?;
|
||||
token.delete(&auth.user.email).await?;
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user