From f8c004630f56914438fa1b114530f639748e41c1 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 16 Sep 2024 22:47:49 +0200 Subject: Add change password functionality Co-authored-by: Stanislav Malishevskiy --- .../src/module/xep/0077_in_band_registration.vala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'xmpp-vala/src/module') diff --git a/xmpp-vala/src/module/xep/0077_in_band_registration.vala b/xmpp-vala/src/module/xep/0077_in_band_registration.vala index baaa4ee0..87b654a8 100644 --- a/xmpp-vala/src/module/xep/0077_in_band_registration.vala +++ b/xmpp-vala/src/module/xep/0077_in_band_registration.vala @@ -30,6 +30,24 @@ public class Module : XmppStreamNegotiationModule { return null; } + public async ErrorStanza? change_password(XmppStream stream, Jid jid, string new_pw) { + StanzaNode pw_change_node = new StanzaNode.build("query", NS_URI).add_self_xmlns(); + StanzaNode username_node = new StanzaNode.build("username", NS_URI); + StanzaNode pw_node = new StanzaNode.build("password", NS_URI); + username_node.put_node(new StanzaNode.text(jid.localpart)); + pw_node.put_node(new StanzaNode.text(new_pw)); + pw_change_node.put_node(username_node); + pw_change_node.put_node(pw_node); + Iq.Stanza set_password_iq = new Iq.Stanza.set(pw_change_node) { to=jid.bare_jid.domain_jid }; + + Iq.Stanza chpw_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, set_password_iq); + if (chpw_result.is_error()) { + return chpw_result.get_error(); + } + + return null; + } + public override bool mandatory_outstanding(XmppStream stream) { return false; } public override bool negotiation_active(XmppStream stream) { return false; } -- cgit v1.2.3-70-g09d2