ruby on rails - Session Timeout Message in RoR using Devise -
ruby on rails - Session Timeout Message in RoR using Devise -
i have application secured devise , session timeout of 30 minutes. devise working normal navigation, if user clicks on link when timed out redirected login screen message saying "your session expired, please sign in 1 time again continue.", excellent.
however have ajax in lot of places. if session times out , user ajax operation want same behavior above rather silently failing 401 error in background.
so far have jquery code on each page grab 401s , reload:
$(document).ajaxerror(function(e, error) { switch(error.status) { case 401: { // unauthorised (possible timeout) location.reload(); break; } it works enough, there annoying issue:
because ajax request hits devise first, when application reloads page directed login page, don't see timeout message, see unauthenticated "you need sign in or sign before continuing." message.
is there way ensure on sec request devise still shows timeout message?
i think need manually show message, illustration redirecting specific url or setting query parameter.
the problem is, after 401 request got new session , when reload browser, next request nail application empty session. that's why unauthenticated message.
ruby-on-rails ajax ruby-on-rails-3 authentication devise
Comments
Post a Comment