Allow changing passwords

This commit is contained in:
Mari 2022-09-05 18:48:38 +02:00 committed by masalachai
parent 1395cd6235
commit cc08819fdc
2 changed files with 7 additions and 2 deletions

View File

@ -19,6 +19,9 @@ pub struct Login<'a> {
/// The password to use for the login /// The password to use for the login
#[serde(rename = "pw", default)] #[serde(rename = "pw", default)]
password: StringValue<'a>, password: StringValue<'a>,
/// A new password which should be set
#[serde(rename = "newPW", default, skip_serializing_if = "Option::is_none")]
new_password: Option<StringValue<'a>>,
/// Data under the <options> tag /// Data under the <options> tag
options: Options<'a>, options: Options<'a>,
/// Data under the <svcs> tag /// Data under the <svcs> tag
@ -27,12 +30,13 @@ pub struct Login<'a> {
} }
impl<'a> Login<'a> { impl<'a> Login<'a> {
pub fn new(username: &'a str, password: &'a str, ext_uris: Option<&'_ [&'a str]>) -> Self { pub fn new(username: &'a str, password: &'a str, new_password: Option<&'a str>, ext_uris: Option<&'_ [&'a str]>) -> Self {
let ext_uris = ext_uris.map(|uris| uris.iter().map(|&u| u.into()).collect()); let ext_uris = ext_uris.map(|uris| uris.iter().map(|&u| u.into()).collect());
Self { Self {
username: username.into(), username: username.into(),
password: password.into(), password: password.into(),
new_password: new_password.map(Into::into),
options: Options { options: Options {
version: EPP_VERSION.into(), version: EPP_VERSION.into(),
lang: EPP_LANG.into(), lang: EPP_LANG.into(),
@ -73,7 +77,7 @@ mod tests {
#[test] #[test]
fn command() { fn command() {
let ext_uris = Some(&["http://schema.ispapi.net/epp/xml/keyvalue-1.0"][..]); let ext_uris = Some(&["http://schema.ispapi.net/epp/xml/keyvalue-1.0"][..]);
let object = Login::new("username", "password", ext_uris); let object = Login::new("username", "password", Some("new-password"), ext_uris);
assert_serialized("request/login.xml", &object); assert_serialized("request/login.xml", &object);
} }

View File

@ -4,6 +4,7 @@
<login> <login>
<clID>username</clID> <clID>username</clID>
<pw>password</pw> <pw>password</pw>
<newPW>new-password</newPW>
<options> <options>
<version>1.0</version> <version>1.0</version>
<lang>en</lang> <lang>en</lang>