aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2024-09-16 22:47:49 +0200
committerfiaxh <git@lightrise.org>2024-09-21 17:06:20 +0100
commitf8c004630f56914438fa1b114530f639748e41c1 (patch)
tree4a9d2ae1de436c00e9d1ac75e05426291be52c4b /xmpp-vala/src/module
parentb09556f03349b51d95c14d1046add355a4754e01 (diff)
downloaddino-f8c004630f56914438fa1b114530f639748e41c1.tar.gz
dino-f8c004630f56914438fa1b114530f639748e41c1.zip
Add change password functionality
Co-authored-by: Stanislav Malishevskiy <stanislav.malishevskiy@gmail.com>
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r--xmpp-vala/src/module/xep/0077_in_band_registration.vala18
1 files changed, 18 insertions, 0 deletions
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; }