account: Add the ability to create an account without any password
Modify the accountcreationwizard and the accountimportexportview to
enable account with no password set.
Change-Id: Id2304f363d0eea8f19d607dedb71f80dea005d8f
diff --git a/src/accountcreationwizard.cpp b/src/accountcreationwizard.cpp
index efaf806..24d8e3f 100644
--- a/src/accountcreationwizard.cpp
+++ b/src/accountcreationwizard.cpp
@@ -542,7 +542,7 @@
gtk_widget_set_sensitive(
priv->button_existing_account_step2_next,
- (strlen(pin) > 0 && strlen(password) > 0)
+ (strlen(pin) > 0)
);
}
@@ -559,8 +559,6 @@
if (
strlen(display_name) > 0 && // Display name is longer than 0
- strlen(password) > 0 && // Password is longer than 0
- strlen(password_confirm) > 0 && // Confirmation is also longer than 0
(
(sign_up_blockchain && strlen(username) > 0 && priv->username_available) || // we are signing up, username is set and avaialble
!sign_up_blockchain // We are not signing up
diff --git a/src/accountimportexportview.cpp b/src/accountimportexportview.cpp
index 46b3fe6..42dbe0a 100644
--- a/src/accountimportexportview.cpp
+++ b/src/accountimportexportview.cpp
@@ -123,7 +123,7 @@
// if accounts and password are set then we're ready for export
auto password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
- if (priv->export_accounts_list && priv->export_accounts_list->data && strlen(password) > 0) {
+ if (priv->export_accounts_list && priv->export_accounts_list->data) {
gtk_widget_set_sensitive(priv->button_export, TRUE);
}
g_free (filename);
@@ -142,11 +142,7 @@
// clear any existing error
gtk_label_set_text(GTK_LABEL(priv->label_error), "");
- // if password is set then we're ready for import
- auto password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
- if (strlen(password) > 0) {
- gtk_widget_set_sensitive(priv->button_import, TRUE);
- }
+ gtk_widget_set_sensitive(priv->button_import, TRUE);
}
static void
@@ -157,27 +153,18 @@
// clear any existing error
gtk_label_set_text(GTK_LABEL(priv->label_error), "");
- // if the password and other requirements are met then enable import/export
- auto password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
- if (strlen(password) > 0) {
+ // import
+ if (auto filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->filechooserbutton_import))) {
+ gtk_widget_set_sensitive(priv->button_import, TRUE);
+ g_free(filename);
+ }
- // import
- if (auto filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->filechooserbutton_import))) {
- gtk_widget_set_sensitive(priv->button_import, TRUE);
- g_free(filename);
- }
-
- // export
- const auto filename = gtk_label_get_text(GTK_LABEL(priv->label_export_location));
- if (strlen(filename) > 0) {
- if (priv->export_accounts_list && priv->export_accounts_list->data) {
- gtk_widget_set_sensitive(priv->button_export, TRUE);
- }
- }
-
- } else {
- gtk_widget_set_sensitive(priv->button_export, FALSE);
- gtk_widget_set_sensitive(priv->button_import, FALSE);
+ // export
+ const auto filename = gtk_label_get_text(GTK_LABEL(priv->label_export_location));
+ if (strlen(filename) > 0
+ && priv->export_accounts_list
+ && priv->export_accounts_list->data) {
+ gtk_widget_set_sensitive(priv->button_export, TRUE);
}
}
@@ -199,21 +186,18 @@
if (auto filepath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(priv->filechooserbutton_import))) {
const auto password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
- if (strlen(password) > 0) {
- auto ret = AccountModel::instance().importAccounts(filepath, password);
- switch(ret) {
- case 0:
- // done
- g_signal_emit(G_OBJECT(self), account_importexport_view_signals[IMPORT_EXPORT_COMPLETED], 0);
- break;
- default:
- //failed
- gtk_label_set_text(GTK_LABEL(priv->label_error), _("Error importing account(s)"));
- g_warning("failed to import account(s), err: %d", ret);
- break;
- }
- } else {
- g_warning("no password set for account import");
+
+ auto ret = AccountModel::instance().importAccounts(filepath, password);
+ switch(ret) {
+ case 0:
+ // done
+ g_signal_emit(G_OBJECT(self), account_importexport_view_signals[IMPORT_EXPORT_COMPLETED], 0);
+ break;
+ default:
+ //failed
+ gtk_label_set_text(GTK_LABEL(priv->label_error), _("Error importing account(s)"));
+ g_warning("failed to import account(s), err: %d", ret);
+ break;
}
g_free(filepath);
} else {
@@ -241,31 +225,26 @@
// validate filepath
if (strlen(filepath)) {
const auto password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
- if (strlen(password) > 0) {
+ // get account id strings
+ auto account_ids = QStringList();
+ auto list = priv->export_accounts_list;
+ while (list != nullptr) {
+ auto account = static_cast<Account *>(list->data);
+ account_ids << account->id();
+ list = g_list_next(list);
+ }
- // get account id strings
- auto account_ids = QStringList();
- auto list = priv->export_accounts_list;
- while (list != nullptr) {
- auto account = static_cast<Account *>(list->data);
- account_ids << account->id();
- list = g_list_next(list);
- }
-
- auto ret = AccountModel::instance().exportAccounts(account_ids, filepath, password);
- switch (ret) {
- case 0:
- // done
- g_signal_emit(G_OBJECT(self), account_importexport_view_signals[IMPORT_EXPORT_COMPLETED], 0);
- break;
- default:
- //failed
- gtk_label_set_text(GTK_LABEL(priv->label_error), _("Error exporting account(s)"));
- g_warning("failed to export account(s), err: %d", ret);
- break;
- }
- } else {
- g_warning("no password set for account export");
+ auto ret = AccountModel::instance().exportAccounts(account_ids, filepath, password);
+ switch (ret) {
+ case 0:
+ // done
+ g_signal_emit(G_OBJECT(self), account_importexport_view_signals[IMPORT_EXPORT_COMPLETED], 0);
+ break;
+ default:
+ //failed
+ gtk_label_set_text(GTK_LABEL(priv->label_error), _("Error exporting account(s)"));
+ g_warning("failed to export account(s), err: %d", ret);
+ break;
}
} else {
g_warning("no file selected for account export");
diff --git a/src/accountmigrationview.cpp b/src/accountmigrationview.cpp
index 1cf09a9..fb09f52 100644
--- a/src/accountmigrationview.cpp
+++ b/src/accountmigrationview.cpp
@@ -174,14 +174,7 @@
const gchar *password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
- if (strlen(password) > 0)
- {
- gtk_widget_set_sensitive(priv->button_migrate_account, TRUE);
- }
- else
- {
- gtk_widget_set_sensitive(priv->button_migrate_account, FALSE);
- }
+ gtk_widget_set_sensitive(priv->button_migrate_account, TRUE);
}
static void