for sync login, return true/false to indicate login success. show login failures...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 26 Mar 2010 20:03:29 +0000 (20:03 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 26 Mar 2010 20:03:29 +0000 (20:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16016 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/css/theme/default.css
Open-ILS/web/js/dojo/openils/User.js
Open-ILS/web/js/ui/base.js
Open-ILS/web/templates/login.tt2

index 2ba93d7..6b59b30 100644 (file)
@@ -56,3 +56,4 @@ body { font-size: 80%; background-color:#FFF; }
     border-bottom:1px solid #ACA899;
 }
 
+.oils-notify-text { color: red; font-weight:bold; }
index ca3c62a..24d6756 100644 (file)
@@ -138,6 +138,10 @@ if(!dojo._hasResource["openils.User"]) {
                 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;
@@ -180,6 +184,8 @@ if(!dojo._hasResource["openils.User"]) {
                 [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;
@@ -189,6 +195,8 @@ if(!dojo._hasResource["openils.User"]) {
                 dojo.require('dojo.cookie');
                 dojo.cookie(_u.authcookie, _u.authtoken, {path:'/'});
             }
+
+            return true;
         },
 
     
index d9dfc83..cd723bf 100644 (file)
@@ -31,6 +31,7 @@ function oilsSetupUser() {
 }
 
 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();
@@ -41,9 +42,14 @@ function oilsDoLogin() {
     };
     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;
 }
 
index faf119a..2c8d971 100644 (file)
@@ -2,6 +2,7 @@
 <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>