mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Refactor prelogin.rs to use default labels for username and password
This commit is contained in:
parent
200d13ef15
commit
159673652c
@ -181,22 +181,24 @@ fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
|||||||
return Ok(Prelogin::Saml(saml_prelogin));
|
return Ok(Prelogin::Saml(saml_prelogin));
|
||||||
}
|
}
|
||||||
|
|
||||||
let label_username = xml::get_child_text(&doc, "username-label");
|
let label_username = xml::get_child_text(&doc, "username-label").unwrap_or_else(|| {
|
||||||
let label_password = xml::get_child_text(&doc, "password-label");
|
info!("Username label has no value, using default");
|
||||||
// Check if the prelogin response is standard login
|
String::from("Username")
|
||||||
if label_username.is_some() && label_password.is_some() {
|
});
|
||||||
|
let label_password = xml::get_child_text(&doc, "password-label").unwrap_or_else(|| {
|
||||||
|
info!("Password label has no value, using default");
|
||||||
|
String::from("Password")
|
||||||
|
});
|
||||||
|
|
||||||
let auth_message =
|
let auth_message =
|
||||||
xml::get_child_text(&doc, "authentication-message").unwrap_or(String::from("Please enter the login credentials"));
|
xml::get_child_text(&doc, "authentication-message").unwrap_or(String::from("Please enter the login credentials"));
|
||||||
let standard_prelogin = StandardPrelogin {
|
let standard_prelogin = StandardPrelogin {
|
||||||
region,
|
region,
|
||||||
is_gateway,
|
is_gateway,
|
||||||
auth_message,
|
auth_message,
|
||||||
label_username: label_username.unwrap(),
|
label_username,
|
||||||
label_password: label_password.unwrap(),
|
label_password,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Prelogin::Standard(standard_prelogin))
|
Ok(Prelogin::Standard(standard_prelogin))
|
||||||
} else {
|
|
||||||
Err(anyhow!("Invalid prelogin response"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user