mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-26 19:56:22 +00:00
Merge pull request #1501 from xenrox/change-password
Add command to change password of logged in user
This commit is contained in:
@@ -149,6 +149,7 @@ static int _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userda
|
||||
static int _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _register_change_password_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
|
||||
static void _iq_free_room_data(ProfRoomInfoData* roominfo);
|
||||
static void _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set);
|
||||
@@ -2629,3 +2630,32 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
iq_register_change_password(const char* const user, const char* const password)
|
||||
{
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t* iq = stanza_change_password(ctx, user, password);
|
||||
|
||||
const char* id = xmpp_stanza_get_id(iq);
|
||||
iq_id_handler_add(id, _register_change_password_result_id_handler, NULL, NULL);
|
||||
|
||||
iq_send_stanza(iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
static int
|
||||
_register_change_password_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
const char* type = xmpp_stanza_get_type(stanza);
|
||||
if (g_strcmp0(type, "error") == 0) {
|
||||
char* error_message = stanza_get_error_message(stanza);
|
||||
cons_show_error("Server error: %s", error_message);
|
||||
log_debug("Password change error: %s", error_message);
|
||||
free(error_message);
|
||||
} else {
|
||||
cons_show("Password successfully changed.");
|
||||
log_debug("Password successfully changed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user