improv(network): use secure_input for Wi-Fi password field
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
parent
8b4e2578ec
commit
a3be974f81
1 changed files with 25 additions and 17 deletions
|
|
@ -51,6 +51,7 @@ enum NewConnectionState {
|
||||||
EnterPassword {
|
EnterPassword {
|
||||||
access_point: AccessPoint,
|
access_point: AccessPoint,
|
||||||
password: String,
|
password: String,
|
||||||
|
password_hidden: bool,
|
||||||
},
|
},
|
||||||
Waiting(AccessPoint),
|
Waiting(AccessPoint),
|
||||||
Failure(AccessPoint),
|
Failure(AccessPoint),
|
||||||
|
|
@ -59,10 +60,7 @@ enum NewConnectionState {
|
||||||
impl NewConnectionState {
|
impl NewConnectionState {
|
||||||
pub fn ssid(&self) -> &str {
|
pub fn ssid(&self) -> &str {
|
||||||
&match self {
|
&match self {
|
||||||
Self::EnterPassword {
|
Self::EnterPassword { access_point, .. } => access_point,
|
||||||
access_point,
|
|
||||||
password: _,
|
|
||||||
} => access_point,
|
|
||||||
Self::Waiting(ap) => ap,
|
Self::Waiting(ap) => ap,
|
||||||
Self::Failure(ap) => ap,
|
Self::Failure(ap) => ap,
|
||||||
}
|
}
|
||||||
|
|
@ -70,10 +68,7 @@ impl NewConnectionState {
|
||||||
}
|
}
|
||||||
pub fn hw_address(&self) -> HwAddress {
|
pub fn hw_address(&self) -> HwAddress {
|
||||||
match self {
|
match self {
|
||||||
Self::EnterPassword {
|
Self::EnterPassword { access_point, .. } => access_point,
|
||||||
access_point,
|
|
||||||
password: _,
|
|
||||||
} => access_point,
|
|
||||||
Self::Waiting(ap) => ap,
|
Self::Waiting(ap) => ap,
|
||||||
Self::Failure(ap) => ap,
|
Self::Failure(ap) => ap,
|
||||||
}
|
}
|
||||||
|
|
@ -84,10 +79,7 @@ impl NewConnectionState {
|
||||||
impl From<NewConnectionState> for AccessPoint {
|
impl From<NewConnectionState> for AccessPoint {
|
||||||
fn from(connection_state: NewConnectionState) -> Self {
|
fn from(connection_state: NewConnectionState) -> Self {
|
||||||
match connection_state {
|
match connection_state {
|
||||||
NewConnectionState::EnterPassword {
|
NewConnectionState::EnterPassword { access_point, .. } => access_point,
|
||||||
access_point,
|
|
||||||
password: _,
|
|
||||||
} => access_point,
|
|
||||||
NewConnectionState::Waiting(access_point) => access_point,
|
NewConnectionState::Waiting(access_point) => access_point,
|
||||||
NewConnectionState::Failure(access_point) => access_point,
|
NewConnectionState::Failure(access_point) => access_point,
|
||||||
}
|
}
|
||||||
|
|
@ -251,6 +243,7 @@ pub(crate) enum Message {
|
||||||
OpenSettings,
|
OpenSettings,
|
||||||
ResetFailedKnownSsid(String, HwAddress),
|
ResetFailedKnownSsid(String, HwAddress),
|
||||||
OpenHwDevice(Option<HwAddress>),
|
OpenHwDevice(Option<HwAddress>),
|
||||||
|
TogglePasswordVisibility,
|
||||||
// Errored(String),
|
// Errored(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -432,6 +425,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
self.new_connection = Some(NewConnectionState::EnterPassword {
|
self.new_connection = Some(NewConnectionState::EnterPassword {
|
||||||
access_point,
|
access_point,
|
||||||
password: String::new(),
|
password: String::new(),
|
||||||
|
password_hidden: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Message::ToggleVisibleNetworks => {
|
Message::ToggleVisibleNetworks => {
|
||||||
|
|
@ -445,6 +439,14 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
*password = entered_pw;
|
*password = entered_pw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::TogglePasswordVisibility => {
|
||||||
|
if let Some(NewConnectionState::EnterPassword {
|
||||||
|
password_hidden, ..
|
||||||
|
}) = &mut self.new_connection
|
||||||
|
{
|
||||||
|
*password_hidden = !*password_hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::SubmitPassword => {
|
Message::SubmitPassword => {
|
||||||
// save password
|
// save password
|
||||||
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
||||||
|
|
@ -456,6 +458,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
if let Some(NewConnectionState::EnterPassword {
|
if let Some(NewConnectionState::EnterPassword {
|
||||||
password,
|
password,
|
||||||
access_point,
|
access_point,
|
||||||
|
..
|
||||||
}) = self.new_connection.take()
|
}) = self.new_connection.take()
|
||||||
{
|
{
|
||||||
let _ = tx.unbounded_send(NetworkManagerRequest::Password(
|
let _ = tx.unbounded_send(NetworkManagerRequest::Password(
|
||||||
|
|
@ -965,6 +968,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
NewConnectionState::EnterPassword {
|
NewConnectionState::EnterPassword {
|
||||||
access_point,
|
access_point,
|
||||||
password,
|
password,
|
||||||
|
password_hidden,
|
||||||
} => {
|
} => {
|
||||||
let id = padded_control(
|
let id = padded_control(
|
||||||
row![
|
row![
|
||||||
|
|
@ -980,11 +984,15 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
let col = padded_control(
|
let col = padded_control(
|
||||||
column![
|
column![
|
||||||
text::body(fl!("enter-password")),
|
text::body(fl!("enter-password")),
|
||||||
text_input("", password)
|
text_input::secure_input(
|
||||||
.on_input(Message::Password)
|
"",
|
||||||
.on_paste(Message::Password)
|
password,
|
||||||
.on_submit(Message::SubmitPassword)
|
Some(Message::TogglePasswordVisibility),
|
||||||
.password(),
|
*password_hidden,
|
||||||
|
)
|
||||||
|
.on_input(Message::Password)
|
||||||
|
.on_paste(Message::Password)
|
||||||
|
.on_submit(Message::SubmitPassword),
|
||||||
container(text::body(fl!("router-wps-button"))).padding(8),
|
container(text::body(fl!("router-wps-button"))).padding(8),
|
||||||
row![
|
row![
|
||||||
button::standard(fl!("cancel"))
|
button::standard(fl!("cancel"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue