From 69e8f39456718b41726f5d392d2a472089a8f692 Mon Sep 17 00:00:00 2001 From: Al McKinlay Date: Mon, 19 Jun 2017 16:26:20 +0100 Subject: [PATCH] Add support for custom registration fields --- packages/node-xmpp-client/lib/Client.js | 5 ++++- packages/node-xmpp-server/lib/C2S/Session.js | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/node-xmpp-client/lib/Client.js b/packages/node-xmpp-client/lib/Client.js index 62cd752ed..4934cad48 100644 --- a/packages/node-xmpp-client/lib/Client.js +++ b/packages/node-xmpp-client/lib/Client.js @@ -370,7 +370,10 @@ Client.prototype.doRegister = function () { to: this.jid.domain }).c('query', {xmlns: NS_REGISTER}) .c('username').t(this.jid.local).up() - .c('password').t(this.password) + .c('password').t(this.password).up() + for (var key in this.options.registrationOptions) { + iq.c(key).t(this.options.registrationOptions[key]).up() + } this.send(iq) var self = this diff --git a/packages/node-xmpp-server/lib/C2S/Session.js b/packages/node-xmpp-server/lib/C2S/Session.js index d7dd19b76..e9496be7c 100644 --- a/packages/node-xmpp-server/lib/C2S/Session.js +++ b/packages/node-xmpp-server/lib/C2S/Session.js @@ -246,12 +246,16 @@ Session.prototype.onRegistration = function (stanza) { proceed() } else if (stanza.attrs.type === 'set') { var jid = new JID(register.getChildText('username'), this.server.options.domain) - this.emit('register', { + var opts = { jid: jid, username: register.getChildText('username'), password: register.getChildText('password'), client: self - }, function (error) { + } + for (var child in register.children) { + opts[register.children[child].name] = register.children[child].getText() + } + this.emit('register', opts, function (error) { if (!error) { self.emit('registration-success', self.jid) } else {