about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-06-05 14:19:41 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-06-05 14:19:41 +0200
commit53ef20927268b777c4845984593bc32a066a1e68 (patch)
tree4d15fa9795f9bd5a6ad860075b103f21759ddb30
parentc03f9363902fbea96c8a2d35c945b52b27c3f701 (diff)
downloadprofani-tty-53ef20927268b777c4845984593bc32a066a1e68.tar.gz
Check if valid account before setting autoconnect
Fixes https://github.com/profanity-im/profanity/issues/1112
-rw-r--r--src/command/cmd_funcs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 999afd10..d44f9d68 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6555,12 +6555,16 @@ cmd_autoconnect(ProfWin *window, const char *const command, gchar **args)
         prefs_set_string(PREF_CONNECT_ACCOUNT, NULL);
         cons_show("Autoconnect account disabled.");
     } else if (strcmp(args[0], "set") == 0) {
-        prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]);
-        cons_show("Autoconnect account set to: %s.", args[1]);
+        if (accounts_account_exists(args[1])) {
+            prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]);
+            cons_show("Autoconnect account set to: %s.", args[1]);
+        } else {
+            cons_show_error("Account '%s' does not exist.", args[1]);
+        }
     } else {
         cons_bad_cmd_usage(command);
     }
-    return true;
+    return TRUE;
 }
 
 gboolean