I am using cblite on android and ios using cordova and i am having custom authentication for sync with gateway. I cannot find a way to call a specific function when my authentication with SG fails when triggering sync process. I need this because i have to go and get a new session in case if the cookie expires or is destroyed by any means.
Below is the code i use for syncing
I notice that there is a function authChallenge which should be called when auth fails but i tried reproducing it by not sending the cookie and calling _replicate, but still the handler does not get called.
Also i recently updated my plugin version from 1.0.0 beta to 1.0.2. Fun fact is the above function was called successfully when my authentication with SG failed in 1.0.0 but now in 1.0.2 it isn't called.
Some more bit of information that i am not able to figure out --> As far as i know when i call trigger sync from my code it first initiates a push replication from cblite to SG and then pull replication from SG to cblite. Now what i am doing is that i am not sending cookies to purposely check what happens and on doing this as soon as i trigger sync the logs on SG show 401 Lo-gin required error which is perfect as i didn't send a cookie. But when i check my network requests on cblite client it shows _replicate request with a session id rep001 in response.
Why does it return a replication session id when SG is showing auth error. Should not it give me a error message in resoponse ?