Gabbr Issimo
Gabbr Issimo

Reputation: 111

Cannot register user on XMPP server

I just started playing with XMPP and i'm at the point where i want to register a new user account. I'm using tigase and xmpp.js. All works fine but when i try to register a user, i get a success response but no user is registered.

This is my code.

const xmpp = client({
  service: "ws://localhost:5290",
  domain: "8662d6b4746d",
});

xmpp.reconnect.stop()
xmpp.timeout = 5000

xmpp.on("online", async (address) => {
  console.log("Online!");
  await xmpp.iqCaller.request(
    xml('iq', {type: 'get', to: '8662d6b4746d'},
      xml('query', {xmlns: 'jabber:iq:register'})
    )
  );
  await xmpp.iqCaller.set(
    xml("query", {xmlns: "jabber:iq:register"},
      xml("username", {}, "username"),
      xml("password", {}, "password"),
      xml("email", {}, "[email protected]")
    ),
    '8662d6b4746d'
  )
});
xmpp.on("status", (status) => {
  console.debug(status);
});
xmpp.on("stanza", async (stanza) => {
  console.log(stanza.toString())
});
xmpp.start().catch(console.error);

This is the response i get from the first iq

<iq from="8662d6b4746d" id="e7t9y4ll60" to="ed0e2dd2-4701-4631-8d16-dfb16b29babf@8662d6b4746d/36525451-tigase-81"
    type="result" xmlns="jabber:client">
<query xmlns="jabber:iq:register">
  <instructions>Please provide the following information to sign up for an account

    Please also provide your e-mail address (must be valid!) to which we will send confirmation link.
  </instructions>
  <x type="form" xmlns="jabber:x:data">
    <title>Account Registration</title>
    <instructions>Please provide the following information to sign up for an account

      Please also provide your e-mail address (must be valid!) to which we will send confirmation link.
    </instructions>
    <field var="FORM_TYPE" type="hidden">
      <value>jabber:iq:register</value>
    </field>
    <field var="username" label="Username" type="text-single">
      <required/>
      <value></value>
    </field>
    <field var="password" label="Password" type="text-private">
      <required/>
      <value></value>
    </field>
    <field var="email" label="Email (MUST BE VALID!)" type="text-single">
      <required/>
      <value></value>
    </field>
  </x>
</query>
</iq>

So i send this xml body

<iq type="set" id="3peq9kolof" xmlns="jabber:client">
<query xmlns="jabber:iq:register">
  <username>user</username>
  <password>pass</password>
  <email>[email protected]</email>
</query>
</iq>

And this is the last response

<iq from="8662d6b4746d" id="qmfce9m3s4" to="ed0e2dd2-4701-4631-8d16-dfb16b29babf@8662d6b4746d/36525451-tigase-81" type="result" xmlns="jabber:client"/>

From what the documentation says, this is how it works and the response is correct but no user is saved in the database. (i'm using an external mysql database with tigase)

The server supports registration from what i see in the features.

<stream:features xmlns:stream="http://etherx.jabber.org/streams">
<sm xmlns="urn:xmpp:sm:3"/>
<register xmlns="http://jabber.org/features/iq-register"/>
<csi xmlns="urn:xmpp:csi:0"/>
<ver xmlns="urn:xmpp:features:rosterver"/>
<sub xmlns="urn:xmpp:features:pre-approval"/>
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
<session xmlns="urn:ietf:params:xml:ns:xmpp-session">
  <optional/>
</session>
<c node="https://tigase.net/tigase-xmpp-server" ver="DVBeLFh/TPj/59OCEybudilMhLM=" hash="SHA-1"
   xmlns="http://jabber.org/protocol/caps"/>
</stream:features>

Upvotes: 0

Views: 284

Answers (0)

Related Questions