esl.client - "auth" failure - the rejected promise is NOT handled
Closed this issue · 8 comments
Line 307 in esl.coffee.md - If the call to client.call.auth(options.password) gets rejected (eg wrong password) - there is no rejection handler.
You should let the esl.client() function receive 3 arguments: options, successHandler, errorHandler.
Then invoke errorHandler if if the auth() call is rejected.
Sorry, I'm having some issues with Docker testing the patch I wrote, so I haven't been able to publish it. That patch will allow you to specify a auth
option to the client
function, which will be used instead of the default @auth
function (in other words, you can specify either password
or auth
). This way you can implement any kind of login logic inside that function (retry, retry with a different password, etc.).
Basically, it will replace
@auth options.password
with
auth = options.auth ? -> @auth options.password
auth.call this
Sounds like overkill. Why would anyone want a different auth logic? Why not just catch the rejected promise from the auth call directly and provide an input errorHandler.
Indeed, given that FreeSwitch doesn't give us chance to re-auth anyhow:
< Content-Type: auth/request
<
> auth barfood
>
< Content-Type: command/reply
< Reply-Text: -ERR invalid
<
< Content-Type: text/disconnect-notice
< Content-Length: 67
<
< Disconnected, goodbye.
< See you at ClueCon! http://www.cluecon.com/
So error handler it is.
It's in version 3.1.0
Great! I added a comment to the code to handle no options
argument.
Oh duh :)
Corrected in 3.1.1, added test, added default_password
export.
super thanks for quick response!