* Event must be freed
*/
oilsEvent* oilsAuthHandleLoginOK(
- jsonObject* userObj, char* uname, char* type, double orgloc ) {
+ jsonObject* userObj, char* uname, char* type, double orgloc, char* workstation ) {
oilsEvent* response;
char* authKey = va_list_to_string(
"%s%s", OILS_AUTH_CACHE_PRFX, authToken );
- osrfLogActivity(OSRF_LOG_MARK, "User %s successfully logged in: %s", uname, authToken );
+ char* ws = (workstation) ? workstation : "";
+ osrfLogActivity(OSRF_LOG_MARK,
+ "successful login: username=%s, authtoken=%s, workstation=%s", uname, authToken, ws );
oilsFMSetString( userObj, "passwd", "" );
jsonObject* cacheObj = jsonParseStringFmt("{\"authtime\": %lf}", timeout);
char* workstation = jsonObjectGetString(jsonObjectGetKey(args, "workstation"));
char* barcode = jsonObjectToSimpleString(jsonObjectGetKey(args, "barcode"));
+ char* ws = (workstation) ? workstation : "";
+
if(!type) type = OILS_AUTH_STAFF;
if(!userObj) {
response = oilsNewEvent( OSRF_LOG_MARK, OILS_EVENT_AUTH_FAILED );
+ osrfLogInfo(OSRF_LOG_MARK, "failed login: username=%s, barcode=%s, workstation=%s", uname, barcode, ws );
osrfAppRespondComplete( ctx, oilsEventToJSON(response) );
oilsEventFree(response);
free(barcode);
free(orgid);
}
+ int freeuname = 0;
+ if(!uname) {
+ uname = oilsFMGetString( userObj, "usrname" );
+ freeuname = 1;
+ }
+
if( passOK ) {
- response = oilsAuthHandleLoginOK( userObj, uname, type, orgloc );
+ response = oilsAuthHandleLoginOK( userObj, uname, type, orgloc, workstation );
} else {
response = oilsNewEvent( OSRF_LOG_MARK, OILS_EVENT_AUTH_FAILED );
- osrfLogInfo(OSRF_LOG_MARK, "Login failed for for %s", uname );
+ osrfLogInfo(OSRF_LOG_MARK, "failed login: username=%s, barcode=%s, workstation=%s", uname, barcode, ws );
}
jsonObjectFree(userObj);
oilsEventFree(response);
free(barcode);
+ if(freeuname) free(uname);
+
return 0;
}