Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am unable to use `ejabberd_auth` in my **helloworld** project

Tags:

I am unable to use ejabberd_auth in my helloworld project.

-behaviour(ejabberd_auth). 
... 
....  
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).  

With that I get the error warning:

helloworld.erl:15: Warning: behaviour ejabberd_auth undefined    


-import(ejabberd_auth, [try_register/3]).  
... 
....  
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).  

With this I get:

exception error: undefined function ejabberd_auth:try_register/3  

Why am I unable to access ejabberd_auth?

I am using IntelliJ Idea, with the Erlang plugin installed.

Thank you all in advance.

UPDATE:
I'm on Ubuntu 16.04 LTS

like image 688
Program-Me-Rev Avatar asked Mar 11 '18 13:03

Program-Me-Rev


1 Answers

I can get you past that error. Here's how...

When I compile a module in the erlang shell, the compiler creates a .beam file in the same directory, which allows me to call functions defined in the module. In your case, if you cd into the directory:

 .../ejabberd/ebin 

you will see all the ejabberd .beam files, including ejabberd_auth.beam. If you start an erlang shell in that directory, then issue your function call (don't compile anything), you won't get that error anymore.

But, then I get the error:

exception error: undefined function jid:nodeprep/1
     in function  ejabberd_auth:validate_credentials/3 (src/ejabberd_auth.erl, line 796)
     in call from ejabberd_auth:try_register/3 (src/ejabberd_auth.erl, line`

There is no jid.beam file in that directory. But:

~/Downloads/ejabberd$ find . -name jid.beam
./deps/xmpp/ebin/jid.beam

You are going to have to figure out how to compile your module so that all the ejabberd modules are available to your program. See: ejabberd how to compile new module.

I am unable to use ejabberd_auth in my helloworld project.

Are you following a tutorial somewhere?

like image 75
7stud Avatar answered Oct 20 '22 06:10

7stud