incorporated ilseents.xml file into opac
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 5 Dec 2005 19:23:45 +0000 (19:23 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 5 Dec 2005 19:23:45 +0000 (19:23 +0000)
added an event entity to lang.dtd

update auth code to return the auth failed event when necessary
updated srfsh to handle the auth event

added a oils_constants file for listing events the C code will use

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2222 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_auth.c
Open-ILS/src/c-apps/oils_constants.h [new file with mode: 0644]
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/web/opac/skin/default/xml/advanced.xml
Open-ILS/web/opac/skin/default/xml/mresult.xml
Open-ILS/web/opac/skin/default/xml/myopac.xml
Open-ILS/web/opac/skin/default/xml/rdetail.xml
Open-ILS/web/opac/skin/default/xml/rresult.xml
OpenSRF/src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm
OpenSRF/src/srfsh/srfsh.c

index 20f39a5..77f6a57 100644 (file)
@@ -3,10 +3,10 @@
 #include "objson/object.h"
 #include "opensrf/log.h"
 #include "oils_utils.h"
+#include "oils_constants.h"
 
 #define OILS_AUTH_CACHE_PRFX "oils_auth_"
 
-
 #define MODULENAME "open-ils.auth"
 
 int osrfAppInitialize();
@@ -94,6 +94,8 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
 
        if( uname && password ) {
 
+               jsonObject* response = jsonParseString("{\"ilsevent\":0}");
+
                /* grab the user object from storage */
                osrfLogDebug( "oilsAuth calling method %s with username %s", storageMethod, uname );
 
@@ -124,8 +126,16 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
                if(!userObj) { /* XXX needs to be a 'friendly' exception */
                        osrfMessageFree(omsg);
                        osrfAppSessionFree(session);
+                       jsonObjectSetKey(response, OILS_ILS_EVENT, 
+                                               jsonNewNumberObject(OILS_ILS_EVENT_AUTH_FAILED));
+                       osrfAppRespondComplete( ctx, response ); 
+                       jsonObjectFree(response);
+                       return 0;
+
+                       /*
                        return osrfAppRequestRespondException( ctx->session, 
                                        ctx->request, "User %s not found in the database", uname );
+                                       */
                }
 
                char* realPassword = oilsFMGetString( userObj, "passwd" ); /**/
@@ -145,11 +155,11 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
                osrfLogDebug( "oilsAuth generated masked password %s. "
                                "Testing against provided password %s", maskedPw, password );
 
-               jsonObject* response;
 
                if( !strcmp( maskedPw, password ) ) {
 
-                       osrfLogInfo( "Login successful for %s", uname );
+                       osrfLogActivity( "User %s successfully logged in", uname );
+
                        char* string = va_list_to_string( "%d.%d.%s", getpid(), time(NULL), uname ); /**/
                        char* authToken = md5sum(string); /**/
                        char* authKey = va_list_to_string( "%s%s", OILS_AUTH_CACHE_PRFX, authToken ); /**/
@@ -158,13 +168,15 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
                        oilsFMSetString( userObj, "passwd", "" );
                        osrfCachePutObject( authKey, userObj, 28800 ); /* XXX config value */
                        osrfLogInternal("oilsAuthComplete(): Placed user object into cache");
-                       response = jsonNewObject( authToken );
+               //      response = jsonNewObject( authToken );
+                       jsonObjectSetKey( response, "authtoken", jsonNewObject(authToken) );    
                        free(string); free(authToken); free(authKey);
 
                } else {
 
+                       jsonObjectSetKey(response, OILS_ILS_EVENT, 
+                                               jsonNewNumberObject(OILS_ILS_EVENT_AUTH_FAILED));
                        osrfLogInfo( "Login failed for for %s", uname );
-                       response = jsonNewNumberObject(0);
                }
 
                osrfLogInternal("oilsAuthComplete responding to client");
diff --git a/Open-ILS/src/c-apps/oils_constants.h b/Open-ILS/src/c-apps/oils_constants.h
new file mode 100644 (file)
index 0000000..1604bc1
--- /dev/null
@@ -0,0 +1,3 @@
+
+#define OILS_ILS_EVENT "ilsevent"                      /* event object key */
+#define OILS_ILS_EVENT_AUTH_FAILED 1000
index fecf4bb..6beb323 100644 (file)
@@ -391,12 +391,20 @@ function doLogin() {
    auth_request.send(true);
    var auth_result = auth_request.result();
 
+       var code = checkILSEvent(auth_result);
+       if(code) {
+               alertILSEvent(code);
+               return null;
+       }
+
+       /*
    if(auth_result == '0' || auth_result == null || auth_result.length == 0) { 
                alert("Login failed");
                return false; 
        }
+       */
 
-       var u = grabUser(auth_result, true);
+       var u = grabUser(auth_result.authtoken, true);
        if(u) runEvt( "common", "locationChanged", u.home_ou(), findOrgDepth(u.home_ou()) );
 
        checkUserSkin();
@@ -599,3 +607,14 @@ function _timerRun(tname) {
 
 
 
+function checkILSEvent(obj) {
+       if( obj.ilsevent != null && obj.ilsevent != 0 )
+               return parseInt(obj.ilsevent);
+       return null;
+}
+function alertILSEvent(code) {
+       /*alert(code);*/
+       alert( $('ilsevent.' + code).innerHTML );
+}
+
+
index 644b301..e08a783 100644 (file)
@@ -23,7 +23,7 @@
 <!--   ======================================================================================= 
                ILS Events
                ======================================================================================= -->
-<!ENTITY ilsevent.1000 "Login failed">
+<!ENTITY ilsevent.1000 "Login failed.  The username or password entered was incorrect.">
 
 
 
index 3f6a5df..cbfdec3 100644 (file)
@@ -23,6 +23,7 @@
                                                <div id='canvas' class='canvas'>
                                                <xi:include href="searchbar.xml"/>
                                                <xi:include href="statusbar.xml"/>
+                                               <xi:include href="ilsevents.xml"/> 
                                                <xi:include href="altcanvas.xml"/>
                                                <div id='canvas_main'>Advanced Search Goes Here</div>
                                        </div>
index 7c8c01b..c9cd331 100644 (file)
@@ -26,6 +26,7 @@
                                                        <xi:include href="searchbar.xml"/>
                                                        <xi:include href="statusbar.xml"/>
                                                        <xi:include href="altcanvas.xml"/>
+                                                       <xi:include href="ilsevents.xml"/> 
                                                        <xi:include href="result_common.xml"/>
                                                </div>
                                                <br/>
index 6e25688..e50ddcc 100644 (file)
@@ -34,6 +34,7 @@
                                                        <xi:include href="searchbar.xml"/>
                                                        <xi:include href="statusbar.xml"/>
                                                        <xi:include href="altcanvas.xml"/>
+                                                       <xi:include href="ilsevents.xml"/> 
 
                                                        <div id='canvas_main'>
 
index 2ce6728..abb6e60 100644 (file)
@@ -31,6 +31,7 @@
                                                        <xi:include href="searchbar.xml"/>
                                                        <xi:include href="statusbar.xml"/>
                                                        <xi:include href="altcanvas.xml"/>
+                                                       <xi:include href="ilsevents.xml"/> 
        
                                                        <div id='canvas_main'>
                                                                <table style='' class='rdetail_header color_1' width='100%'>
index ca14d50..f33e215 100644 (file)
@@ -27,6 +27,7 @@
                                                <xi:include href="searchbar.xml"/>
                                                <xi:include href="statusbar.xml"/>
                                                <xi:include href="altcanvas.xml"/>
+                                               <xi:include href="ilsevents.xml"/> 
                                                <xi:include href="result_common.xml"/>
                                        </div>
                                        <br/>
index d903395..810d9d8 100644 (file)
@@ -468,13 +468,13 @@ sub initialize {
        # --- 5 tries to connect to the jabber server
        my $socket;
        for(1..5) {
-               $logger->transport( "$jid: Attempting to connect to server...$host:$port (Try # $_)", WARN );
                $socket = $sock_type->new( PeerHost => $host,
                                           PeerPort => $port,
                                           Peer => $port,
                                           Proto    => 'tcp' );
-               $logger->transport( "$jid: $_ connect attempt to $host:$port", WARN );
+               $logger->debug( "$jid: $_ connect attempt to $host:$port");
                last if ( $socket and $socket->connected );
+               $logger->warn( "$jid: Failed to connect to server...$host:$port (Try # $_)");
                sleep 3;
        }
 
index 445139e..294c5d5 100644 (file)
@@ -277,8 +277,12 @@ int handle_login( char* words[]) {
 
                parse_request( buf2 );
 
-               char* x = jsonObjectGetString(last_result->_result_content);
-               if(x) login_session = strdup(x);
+               jsonObject* x = last_result->_result_content;
+               if(x) {
+                       char* authtoken = jsonObjectGetString(jsonObjectGetKey(x, "authtoken"));
+                       if(authtoken) login_session = strdup(authtoken);
+                       else login_session = NULL;
+               }
                else login_session = NULL;
 
                printf("Login Session: %s\n", login_session );