From 1dc88b5e3c54e1da3b0445f2725e8e5a043403f9 Mon Sep 17 00:00:00 2001 From: Shannon Sterz Date: Wed, 19 Jun 2024 11:54:17 +0200 Subject: [PATCH] access-control: move to flatten `User` into `UserWithToken` Signed-off-by: Shannon Sterz --- proxmox-access-control/src/types.rs | 46 ++++------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/proxmox-access-control/src/types.rs b/proxmox-access-control/src/types.rs index 9ed4e9cd..88b91a9f 100644 --- a/proxmox-access-control/src/types.rs +++ b/proxmox-access-control/src/types.rs @@ -40,32 +40,9 @@ pub const EMAIL_SCHEMA: Schema = StringSchema::new("E-Mail Address.") #[api( properties: { - userid: { - type: Userid, - }, - comment: { - optional: true, - schema: COMMENT_SCHEMA, - }, - enable: { - optional: true, - schema: ENABLE_USER_SCHEMA, - }, - expire: { - optional: true, - schema: EXPIRE_USER_SCHEMA, - }, - firstname: { - optional: true, - schema: FIRST_NAME_SCHEMA, - }, - lastname: { - schema: LAST_NAME_SCHEMA, - optional: true, - }, - email: { - schema: EMAIL_SCHEMA, - optional: true, + user: { + type: User, + flatten: true, }, tokens: { type: Array, @@ -91,19 +68,8 @@ pub const EMAIL_SCHEMA: Schema = StringSchema::new("E-Mail Address.") #[serde(rename_all = "kebab-case")] /// User properties with added list of ApiTokens pub struct UserWithTokens { - pub userid: Userid, - #[serde(skip_serializing_if = "Option::is_none")] - pub comment: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub enable: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub expire: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub firstname: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub lastname: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub email: Option, + #[serde(flatten)] + pub user: User, #[serde(skip_serializing_if = "Vec::is_empty", default)] pub tokens: Vec, #[serde(skip_serializing_if = "bool_is_false", default)] @@ -193,7 +159,7 @@ impl ApiToken { }, } )] -#[derive(Serialize, Deserialize, Updater, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Updater, PartialEq, Eq, Clone)] /// User properties. pub struct User { #[updater(skip)]