Add command to change password of logged in user

This commit is contained in:
Thorben Günther
2021-03-11 13:56:06 +01:00
parent 71236a0d5a
commit b0aea2bcff
9 changed files with 138 additions and 1 deletions

View File

@@ -2739,3 +2739,40 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
return iq;
}
xmpp_stanza_t*
stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* const password)
{
char* id = connection_create_stanza_id();
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id);
xmpp_stanza_t* change_password = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(change_password, STANZA_NAME_QUERY);
xmpp_stanza_set_ns(change_password, STANZA_NS_REGISTER);
xmpp_stanza_t* username_st = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(username_st, STANZA_NAME_USERNAME);
xmpp_stanza_t* username_text = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(username_text, user);
xmpp_stanza_add_child(username_st, username_text);
xmpp_stanza_release(username_text);
xmpp_stanza_t* password_st = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(password_st, STANZA_NAME_PASSWORD);
xmpp_stanza_t* password_text = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(password_text, password);
xmpp_stanza_add_child(password_st, password_text);
xmpp_stanza_release(password_text);
xmpp_stanza_add_child(change_password, username_st);
xmpp_stanza_release(username_st);
xmpp_stanza_add_child(change_password, password_st);
xmpp_stanza_release(password_st);
xmpp_stanza_add_child(iq, change_password);
xmpp_stanza_release(change_password);
return iq;
}