diff options
author | Thorben Günther <admin@xenrox.net> | 2021-03-11 13:56:06 +0100 |
---|---|---|
committer | Thorben Günther <admin@xenrox.net> | 2021-03-11 17:42:53 +0100 |
commit | b0aea2bcffc760fb4a2041ed0ab20bac40278289 (patch) | |
tree | 638827f80d58452d0c15dddaf408aad6bee00cb4 /src/command | |
parent | 71236a0d5a47277d55caa5a09befa97ccabe7fec (diff) | |
download | profani-tty-b0aea2bcffc760fb4a2041ed0ab20bac40278289.tar.gz |
Add command to change password of logged in user
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_defs.c | 13 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 27 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 1 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 49c9bf95..3493b214 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2564,6 +2564,19 @@ static struct cmd_t command_defs[] = { CMD_NOEXAMPLES }, + { "/changepassword", + parse_args, 0, 0, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_change_password) + CMD_NOTAGS + CMD_SYN( + "/changepassword") + CMD_DESC( + "Change password of logged in account") + CMD_NOARGS + CMD_NOEXAMPLES + }, + // NEXT-COMMAND (search helper) }; diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 60b7010b..77422dc6 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -9298,3 +9298,30 @@ cmd_mam(ProfWin* window, const char* const command, gchar** args) return TRUE; } + +gboolean +cmd_change_password(ProfWin* window, const char* const command, gchar** args) +{ + jabber_conn_status_t conn_status = connection_get_status(); + + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } + + char* user = connection_get_user(); + char* passwd = ui_ask_password(false); + char* confirm_passwd = ui_ask_password(true); + + if (g_strcmp0(passwd, confirm_passwd) == 0) { + iq_register_change_password(user, passwd); + } else { + cons_show("Aborted! The new password and the confirmed password do not match."); + } + + free(user); + free(passwd); + free(confirm_passwd); + + return TRUE; +} diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index bcd634da..5a192efb 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -159,6 +159,7 @@ gboolean cmd_charset(ProfWin* window, const char* const command, gchar** args); gboolean cmd_console(ProfWin* window, const char* const command, gchar** args); gboolean cmd_command_list(ProfWin* window, const char* const command, gchar** args); gboolean cmd_command_exec(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_change_password(ProfWin* window, const char* const command, gchar** args); gboolean cmd_plugins(ProfWin* window, const char* const command, gchar** args); gboolean cmd_plugins_sourcepath(ProfWin* window, const char* const command, gchar** args); |