【问题标题】:Anyone know how to change username and password with strophe.js?有人知道如何使用 strophe.js 更改用户名和密码吗?
【发布时间】:2018-02-08 11:39:39
【问题描述】:

我正在构建一个 XMPP 聊天应用程序,我使用了 strophe.js,但我不知道如何使用 strophe 更改用户名和密码。提前致谢。

【问题讨论】:

  • 你检查我的答案了吗?

标签: xmpp strophe strophe.js


【解决方案1】:

您无法更改用户名,因为它是在注册到 XMPP 服务器时创建的 JID,即用户的唯一标识符。

相反,您可以根据xep-0077 - In-Band Registration更改密码

使用 Strophe.js 的代码是:

function setPwd(pwd) {
    // jid is user account (i.e. myname@server.com)
    // name is user name (i.e. myname), must be equal to first part of jid
    var iq = $iq({
        type: 'set',
        to: jid,
        }).c('query', {
            xmlns: 'jabber:iq:register'
        })
        .c('username').t(name).up()
        .c('password').t(pwd);
    connection.sendIQ(iq, function(iq) {
        console.log("setPwd-callback", iq);
    });
}

【讨论】:

    猜你喜欢
    • 2018-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    • 1970-01-01
    相关资源
    最近更新 更多