mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 05:26:21 +00:00
Add command to change password of logged in user
This commit is contained in:
@@ -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)
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user