[fractal/not-so-secret: 7/8] passwd: improve password storage error handling
- From: Alejandro Domínguez <aledomu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/not-so-secret: 7/8] passwd: improve password storage error handling
- Date: Mon, 4 Jan 2021 18:05:51 +0000 (UTC)
commit 0080a7e0723eb3bea9ae981b3c1d002c2f07312c
Author: Alexandre Franke <afranke gnome org>
Date: Mon Jan 4 09:59:57 2021 +0100
passwd: improve password storage error handling
fractal-gtk/src/appop/login.rs | 14 ++++++++------
fractal-gtk/src/passwd.rs | 4 ++--
2 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/fractal-gtk/src/appop/login.rs b/fractal-gtk/src/appop/login.rs
index 8f86a709..211e167f 100644
--- a/fractal-gtk/src/appop/login.rs
+++ b/fractal-gtk/src/appop/login.rs
@@ -85,16 +85,18 @@ impl AppOp {
server: Url,
identity: Box<ServerName>,
) {
- self.store_pass(
+ match self.store_pass(
username.clone(),
password.clone(),
server.clone(),
identity.clone(),
- )
- .unwrap_or_else(|_| {
- // TODO: show an error
- error!("Can't store the password using libsecret");
- });
+ ) {
+ Err(SsError::Locked) => error!("Can’t store the password, keyring is locked."),
+ Err(SsError::Dbus(_)) => {
+ error!("Can’t store the password, no Secret Service available.")
+ }
+ _ => (),
+ };
RUNTIME.spawn(async move {
match register::login(username, password, server.clone()).await {
diff --git a/fractal-gtk/src/passwd.rs b/fractal-gtk/src/passwd.rs
index 995aa3e0..714342cf 100644
--- a/fractal-gtk/src/passwd.rs
+++ b/fractal-gtk/src/passwd.rs
@@ -39,7 +39,7 @@ pub trait PasswordStorage {
password: String,
server: Url,
identity: Box<ServerName>,
- ) -> Result<(), Error> {
+ ) -> Result<(), secret_service::SsError> {
ss_storage::store_pass(username, password, server, identity)
}
@@ -140,7 +140,7 @@ mod ss_storage {
password: String,
server: Url,
identity: Box<ServerName>,
- ) -> Result<(), Error> {
+ ) -> Result<(), secret_service::SsError> {
let ss = SecretService::new(EncryptionType::Dh)?;
let collection = get_default_collection_unlocked(&ss)?;
let key = "fractal";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]