var authReq = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.authenticate.complete', loginInfo);
authReq.oncomplete = function(rr) {
var data = rr.recv().content();
+
+ if(!data || !data.payload)
+ throw new Error("Login Failed: " + js2JSON(data));
+
_u.authtoken = data.payload.authtoken;
if (!openils.User.authtoken) openils.User.authtoken = _u.authtoken;
_u.authtime = data.payload.authtime;
[loginInfo]
);
+ if(!data || !data.payload) return false;
+
_u.authtoken = data.payload.authtoken;
if (!openils.User.authtoken) openils.User.authtoken = _u.authtoken;
_u.authtime = data.payload.authtime;
dojo.require('dojo.cookie');
dojo.cookie(_u.authcookie, _u.authtoken, {path:'/'});
}
+
+ return true;
},
}
function oilsDoLogin() {
+ openils.Util.hide('oils-login-failed');
var cgi = new openils.CGI();
var workstation = cgi.param('ws') || dojo.cookie('ws');
var user = new openils.User();
};
if(workstation)
args.workstation = workstation;
- user.login(args);
- dojo.cookie('ses', user.authtoken, {path : '/'});
- location.href = location.href;
+
+ if(user.login(args)) {
+ dojo.cookie('ses', user.authtoken, {path : '/'});
+ location.href = location.href;
+ } else {
+ openils.Util.show('oils-login-failed');
+ }
+
return false;
}
<div style='display:none;' dojoType="dijit.Dialog" jsId='oilsLoginDialog' class='oils-login-dialog'>
<script>dojo.require('dijit.form.TextBox');</script>
<b>Please Login</b>
+ <div class='hidden oils-notify-text' id='oils-login-failed'>Login Failed</div>
<form>
<table>
<tr>