Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find any error handling callback #42

Open
dayton-outar opened this issue Feb 9, 2017 · 2 comments
Open

Cannot find any error handling callback #42

dayton-outar opened this issue Feb 9, 2017 · 2 comments
Assignees
Labels

Comments

@dayton-outar
Copy link

The idletimeout plugins sends the KeepAlive request at regular intervals. There comes a time when the application will return a HTTP 403 (Forbidden) because the user session no longer authenticates (for whatever permission reasons).

I want to handle the 403 error to log out the user. How do I do this?

(n.b. I have the timeout working properly when the session is about to timeout but sometimes the session is bumped out, either because the application is restarted or otherwise).

@JillElaine
Copy link
Owner

Use the 'testing' script, https://github.com/JillElaine/jquery-idleTimeout/blob/master/jquery-idleTimeout-for-testing.js, and watch the console for feedback. It's a good way to understand the script and hopefully spot when your 403 occurs. Add and remove the console log messages to make the console suit your purposes.

You may need to adjust your server to get the 403 response to occur frequently enough to be useful for testing.

I searched for solutions to "javascript detect 403 error", and found several articles. Perhaps the most promising solution is here: http://stackoverflow.com/questions/22106522/unable-to-detect-403-status-code-in-jquery-ajax-call?rq=1

If you are able to detect the 403 error, you can call the logoutUser() function.

Please post back with information on your methods. Your efforts will help others.

@JillElaine JillElaine self-assigned this Feb 9, 2017
@dayton-outar
Copy link
Author

I'm able to get feedback from the application when I get a 403 response from the AJAX request sent from idleTimeout. I need to check again, if there are any callbacks of the plugin that exposes the error callback of the AJAX call.

I usually like to implement my global function that does the redirecting based on the HTTP status code from each AJAX call. If this is not possible, I can always try the Global .ajaxError() callback to trap the 403 error. It should work like window.onerror only that it will capture ajax call instead of any JavaScript error happening in the browser.

I will return to confirm if this approach works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants