asmack XMPP new user registration

后端 未结 7 1375
鱼传尺愫
鱼传尺愫 2021-02-04 20:50

Good people of StackOverflow, please help. I\'ve set up an ejabberd server on my ubuntu machine, added virtual host, set {access, register, [{allow, all}]}. and registered

相关标签:
7条回答
  • 2021-02-04 21:06

    I came across the same issue and found the solution:

    Make changes in server

    After loggin in ejabbered from ur admin interface. Go to Virtual Host-Nodes-Modules-mod_register and add:

    [{welcome_message,  {"Welcome!", "Welcome to this Jabber server."}}, {access_from, register}]
    

    n u ll b able to create account successfully from your client

    0 讨论(0)
  • 2021-02-04 21:08

    Had you specified the ip_access option in mod_register? If Pidgin and your ejabberd server are somehow both using the same IP, then a default rule that looks something like this:

    {mod_register, [
        ...
        %%
        %% Only clients in the server machine can register accounts
        %%
        {ip_access, [{allow, "127.0.0.0/8"},
                     {deny, "0.0.0.0/0"}]},
        ...
    ] ...
    

    would allow both of those IPs to register accounts, but not an Android client that was using a different IP.

    I've been facing a related problem, and for some reason the {access_from, register_from} solution that worked for you did not work as expected for me. Were you able to restrict the ability to create new accounts to only an admin user?

    0 讨论(0)
  • 2021-02-04 21:12

    To register a new user using smack library after logging in through admin or some other account.

    /** * To Register a New Client On Jabber Server */

    public void registerUser()
    {
        AccountManager manager = connection.getAccountManager();
        try {
            manager.createAccount("Romain Guy","halejag");//username & paswd
    
    
        } catch (XMPPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    0 讨论(0)
  • 2021-02-04 21:17

    Try with following changes in ejabberd.cfg.

    %%{ip_access, [
    %% {allow, "127.0.0.0/8"},
    %% {deny, "0.0.0.0/0"}]}
    

    along with -

    %% In-band registration
    {access, register, [{allow, all}]}.
    

    &

    {mod_register, [
          {access_from, register},
           ...
                    ] 
    

    I hope now it will work for you.

    0 讨论(0)
  • 2021-02-04 21:21

    Works for me this code to register a new account:

    try
    {
        connection.connect ();
        Log.i (TAG, "Connect");
        mAccount = new AccountManager (connection);
        if (mAccount.supportsAccountCreation ())
        {
            mAccount.createAccount ("user", "pass");
        }
    

    with the following settings ejabberd:

    {access, register, [{allow, all}]}.

    It is a very secure setup because it can record without our authenticated accounts on the server (the method supports.AccountCreation () returns us true).

    0 讨论(0)
  • 2021-02-04 21:23

    I found it! The problem is in server configuration (but I still don't understand why I could register new user from Pidgin before this change). Setting

    %% In-band registration
    {access, register, [{allow, all}]}.
    

    doesn't seem to work with new versions of ejabberd. You need to add

    {mod_register, [
          {access_from, register},
           ...
                    ] ...
    

    if You want to allow all users to register. If You want only admin to have this access, then you need to add new access rule

    {access, register_from, [{allow, admin}]}.
    

    and

    {mod_register, [
          {access_from, register_from},
           ...
                    ] ...
    
    0 讨论(0)
提交回复
热议问题