if(e = openils.Event.parse(testval)) {
if(eventOk) return e;
console.log(e.toString());
- if(openils.Util.alertEvent)
+
+ // session timed out. Stop propagation of requests queued by Util.onload
+ // and launch the XUL login dialog if possible
+ var retryLogin = false;
+ if(e.textcode == 'NO_SESSION') {
+ openils.User.authtoken = null;
+ if(openils.XUL.isXUL()) {
+ retryLogin = true;
+ openils.XUL.getNewSession( function() { location.href = location.href } );
+ } else {
+ // TODO: make the oilsLoginDialog templated via dojo so it can be
+ // used as a standalone widget
+ }
+ }
+
+ if(openils.Util.alertEvent && !retryLogin)
alert(e);
return null;
}
var authtoken = cgi.param('ses') || dojo.cookie('ses');
var workstation = cgi.param('ws') || dojo.cookie('ws');
var user;
+ var ses_user;
openils.User.user = null;
openils.User.authtoken = null;
openils.User.workstation = null;
- if(!authtoken && openils.XUL.isXUL()) {
+ if(openils.XUL.isXUL()) {
stash = openils.XUL.getStash();
authtoken = stash.session.key
+ ses_user = stash.list.au[0];
}
if(authtoken) {
user = new openils.User();
delete user.sessionCache[authtoken];
user.authtoken = authtoken;
+ if(ses_user) {
+ user.user = ses_user;
+ user.sessionCache[authtoken] = ses_user;
+ }
user.user = user.getBySession();
}