char* active = oilsFMGetString(card, "active");
if( ! oilsUtilsIsDBTrue(active) ) {
+ free(active);
osrfLogInfo(OSRF_LOG_MARK, "barcode %s is not active, returning event", barcode);
return oilsNewEvent(OSRF_LOG_MARK, "PATRON_CARD_INACTIVE");
}
+
+ free(active);
return NULL;
}
return 0;
}
- /* check to see if the user is allowed to login */
- if( oilsAuthCheckLoginPerm( ctx, userObj, type ) == -1 ) {
- jsonObjectFree(userObj);
+ /* first let's see if they have the right credentials */
+ int passOK = -1;
+ if(uname) passOK = oilsAuthVerifyPassword( ctx, userObj, uname, password );
+ else if (barcode)
+ passOK = oilsAuthVerifyPassword( ctx, userObj, barcode, password );
+
+ if( passOK < 0 ) {
+ free(barcode);
+ return passOK;
+ }
+
+ /* first see if their account is inactive */
+ char* active = oilsFMGetString(userObj, "active");
+ if( !oilsUtilsIsDBTrue(active) ) {
+ response = oilsNewEvent(OSRF_LOG_MARK, "PATRON_INACTIVE");
+ osrfAppRespondComplete( ctx, oilsEventToJSON(response) );
+ oilsEventFree(response);
free(barcode);
+ free(active);
return 0;
}
+ free(active);
- osrfLogDebug(OSRF_LOG_MARK, "BARCODE = %s", barcode);
+ /* then see if the barcode they used is active */
if( barcode && (response = oilsAuthCheckCard( ctx, userObj, barcode )) ) {
osrfAppRespondComplete( ctx, oilsEventToJSON(response) );
oilsEventFree(response);
return 0;
}
-
- int passOK = -1;
- if(uname) passOK = oilsAuthVerifyPassword( ctx, userObj, uname, password );
- else if (barcode)
- passOK = oilsAuthVerifyPassword( ctx, userObj, barcode, password );
- if( passOK < 0 ) {
+ /* check to see if the user is even allowed to login */
+ if( oilsAuthCheckLoginPerm( ctx, userObj, type ) == -1 ) {
+ jsonObjectFree(userObj);
free(barcode);
- return passOK;
+ return 0;
}
+
/* if a workstation is defined, flesh the user with the workstation info */
if( workstation != NULL ) {