Register Account
new accounts can be registered using XEP-0077 In-Band Registration when supported by the XMPP server.
It is not recommended to enable In-Band Registration on public servers. It opens a server for malicious usage.
It more secure to register accounts over a website or other services, using captchas and additional token verification by
Email, SMS and others. There are many ways to interact directly with the user accounts storage of a XMPP server.
implementation of IRegister
public class RegisterAccountHandler : IRegister
{
private XmppClient xmppClient;
public RegisterAccountHandler(XmppClient xmppClient)
{
this.xmppClient = xmppClient;
}
public bool RegisterNewAccount => true;
public async Task<Register> RegisterAsync(Register register)
{
return await Task<Register>.Run(() =>
{
register.RemoveAll<Data>();
register.Username = xmppClient.Username;
register.Password = xmppClient.Password;
return register;
});
}
}
connect and register a new account
var xmppClient = new XmppClient()
{
Username = "bob",
Password = "secret",
XmppDomain = "example.com"
};
// set our RegisterAccountHandler
xmppClient.RegistrationHandler = new RegisterAccountHandler(xmppClient);
await xmppClient.ConnectAsync();