From 7d4e362993925b4fef003303a3e30bc773d2f470 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 19 May 2020 09:49:39 +0200 Subject: [PATCH] depend on proxmox 0.1.32, src/api2/access/user.rs: simplify code --- Cargo.toml | 2 +- src/api2/access/user.rs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c84a5d371..283d6139e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ pam = "0.7" pam-sys = "0.5" percent-encoding = "2.1" pin-utils = "0.1.0" -proxmox = { version = "0.1.31", features = [ "sortable-macro", "api-macro" ] } +proxmox = { version = "0.1.32", features = [ "sortable-macro", "api-macro" ] } #proxmox = { git = "ssh://gitolite3@proxdev.maurer-it.com/rust/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] } #proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro" ] } regex = "1.2" diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs index 27b2c8089..6e381cd55 100644 --- a/src/api2/access/user.rs +++ b/src/api2/access/user.rs @@ -88,24 +88,22 @@ pub fn list_users( }, )] /// Create new user. -pub fn create_user(userid: String, password: Option, param: Value) -> Result<(), Error> { +pub fn create_user(password: Option, param: Value) -> Result<(), Error> { let _lock = crate::tools::open_file_locked(user::USER_CFG_LOCKFILE, std::time::Duration::new(10, 0))?; - let mut data = param.clone(); - data["userid"] = Value::from(userid.clone()); - let user: user::User = serde_json::from_value(data)?; + let user: user::User = serde_json::from_value(param)?; let (mut config, _digest) = user::config()?; - if let Some(_) = config.sections.get(&userid) { - bail!("user '{}' already exists.", userid); + if let Some(_) = config.sections.get(&user.userid) { + bail!("user '{}' already exists.", user.userid); } - let (username, realm) = crate::auth::parse_userid(&userid)?; + let (username, realm) = crate::auth::parse_userid(&user.userid)?; let authenticator = crate::auth::lookup_authenticator(&realm)?; - config.set_data(&userid, "user", &user)?; + config.set_data(&user.userid, "user", &user)?; user::save_config(&config)?;