Loading client/client.cpp +8 −3 Changes for client/client.cpp: 8 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -261,13 +261,14 @@ void authdb::client::Client::SessionInfo(class SessionData& sdat){ } bool authdb::client::Client::UserLogout(){ #include <iostream> bool authdb::client::Client::remSession(){ json_object *jresponse = json_object_new_object(); json_object *cmd=json_object_new_array(); json_object *obj=json_object_new_object(); json_object_object_add(obj,"usersession", json_object_new_string(_Con.getSessionID().c_str())); json_object_object_add(obj,"userlogout",json_object_new_string(_Con.getSessionID().c_str())); json_object_object_add(obj,"remsession",json_object_new_string(_Con.getSessionID().c_str())); json_object_array_add(cmd,obj); Loading @@ -281,10 +282,14 @@ bool authdb::client::Client::UserLogout(){ std::copy(tmp,tmp+outsize,std::back_inserter(out)); std::cout << tmp << std::endl; std::vector<char> resp(_Con._Client->Post(_Con._Url.getPath(),"text/json",out)); resp.push_back('\0'); std::cout << resp.data() <<std::endl; json_object_put(jresponse); json_object *jrequest; Loading @@ -303,7 +308,7 @@ bool authdb::client::Client::UserLogout(){ for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(jrequest,i), key, val) { if(strcmp(key,"userlogout")==0){ if(strcmp(_Con.getSessionID().c_str(),json_object_get_string(val)) == 0 ){ if(strcmp(_Con.getSessionID().c_str(),"failed") != 0 ){ json_object_put(jrequest); json_tokener_free(jtok); return true; Loading client/client.h +1 −1 Changes for client/client.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -70,12 +70,12 @@ namespace authdb { bool UserAuth(); bool ClientAuth(); bool UserLogout(); void addConnection(const std::string &clientname,const std::string &cltsecret); void remConnection(const std::string &clientname); void SessionInfo(class SessionData &sdat); bool remSession(); bool GPOcheck(class uuid gpoid); Loading src/api.cpp +14 −8 Changes for src/api.cpp: 14 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -366,7 +366,7 @@ namespace authdb { } } void UserLogout(json_object *request,json_object *response){ void remSession(json_object *request,json_object *response){ std::lock_guard<std::mutex> lock(AuthClientLock); json_object *cmd=json_object_object_get(request,"commands"); Loading @@ -376,14 +376,22 @@ namespace authdb { int fcount = json_object_array_length(cmd); for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) { if(strcmp(key,"userlogout")==0){ uuid tmp; if(strcmp(key,"remsession")==0){ uuid tmp,stmp; tmp.parse(json_object_get_string(val)); _SessionData->getUid(tmp); _SessionData->getUid(stmp); std::cout << tmp.c_str() << ": " << stmp.c_str() << std::endl; if(tmp==stmp){ AuthSession.remSession(tmp); json_object *slogoff=json_object_new_object(); json_object_object_add(slogoff,"userlogout", json_object_new_string(tmp.c_str())); json_object_object_add(slogoff,"remsession", json_object_new_string(tmp.c_str())); json_object_array_add(response,slogoff); return; }else{ json_object *slogoff=json_object_new_object(); json_object_object_add(slogoff,"remsession", json_object_new_string("failed")); json_object_array_add(response,slogoff); } } } } Loading Loading @@ -440,7 +448,7 @@ namespace authdb { Connection(jrequest,jresponse); SessionInfo(jrequest,jresponse); UserLogout(jrequest,jresponse); remSession(jrequest,jresponse); if(! (curcon=checkConnection(jrequest,jresponse)) ){ if(! (curcon=ClientLogin(jrequest,jresponse)) ){ Loading @@ -461,8 +469,6 @@ namespace authdb { size_t outsize=0; const char *out=json_object_to_json_string_length(jresponse,0,&outsize); std::cout << out << std::endl; rep.setState(HTTP200); rep.setContentType("text/json"); rep.send(curreq,out,outsize); Loading Loading
client/client.cpp +8 −3 Changes for client/client.cpp: 8 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -261,13 +261,14 @@ void authdb::client::Client::SessionInfo(class SessionData& sdat){ } bool authdb::client::Client::UserLogout(){ #include <iostream> bool authdb::client::Client::remSession(){ json_object *jresponse = json_object_new_object(); json_object *cmd=json_object_new_array(); json_object *obj=json_object_new_object(); json_object_object_add(obj,"usersession", json_object_new_string(_Con.getSessionID().c_str())); json_object_object_add(obj,"userlogout",json_object_new_string(_Con.getSessionID().c_str())); json_object_object_add(obj,"remsession",json_object_new_string(_Con.getSessionID().c_str())); json_object_array_add(cmd,obj); Loading @@ -281,10 +282,14 @@ bool authdb::client::Client::UserLogout(){ std::copy(tmp,tmp+outsize,std::back_inserter(out)); std::cout << tmp << std::endl; std::vector<char> resp(_Con._Client->Post(_Con._Url.getPath(),"text/json",out)); resp.push_back('\0'); std::cout << resp.data() <<std::endl; json_object_put(jresponse); json_object *jrequest; Loading @@ -303,7 +308,7 @@ bool authdb::client::Client::UserLogout(){ for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(jrequest,i), key, val) { if(strcmp(key,"userlogout")==0){ if(strcmp(_Con.getSessionID().c_str(),json_object_get_string(val)) == 0 ){ if(strcmp(_Con.getSessionID().c_str(),"failed") != 0 ){ json_object_put(jrequest); json_tokener_free(jtok); return true; Loading
client/client.h +1 −1 Changes for client/client.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -70,12 +70,12 @@ namespace authdb { bool UserAuth(); bool ClientAuth(); bool UserLogout(); void addConnection(const std::string &clientname,const std::string &cltsecret); void remConnection(const std::string &clientname); void SessionInfo(class SessionData &sdat); bool remSession(); bool GPOcheck(class uuid gpoid); Loading
src/api.cpp +14 −8 Changes for src/api.cpp: 14 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -366,7 +366,7 @@ namespace authdb { } } void UserLogout(json_object *request,json_object *response){ void remSession(json_object *request,json_object *response){ std::lock_guard<std::mutex> lock(AuthClientLock); json_object *cmd=json_object_object_get(request,"commands"); Loading @@ -376,14 +376,22 @@ namespace authdb { int fcount = json_object_array_length(cmd); for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) { if(strcmp(key,"userlogout")==0){ uuid tmp; if(strcmp(key,"remsession")==0){ uuid tmp,stmp; tmp.parse(json_object_get_string(val)); _SessionData->getUid(tmp); _SessionData->getUid(stmp); std::cout << tmp.c_str() << ": " << stmp.c_str() << std::endl; if(tmp==stmp){ AuthSession.remSession(tmp); json_object *slogoff=json_object_new_object(); json_object_object_add(slogoff,"userlogout", json_object_new_string(tmp.c_str())); json_object_object_add(slogoff,"remsession", json_object_new_string(tmp.c_str())); json_object_array_add(response,slogoff); return; }else{ json_object *slogoff=json_object_new_object(); json_object_object_add(slogoff,"remsession", json_object_new_string("failed")); json_object_array_add(response,slogoff); } } } } Loading Loading @@ -440,7 +448,7 @@ namespace authdb { Connection(jrequest,jresponse); SessionInfo(jrequest,jresponse); UserLogout(jrequest,jresponse); remSession(jrequest,jresponse); if(! (curcon=checkConnection(jrequest,jresponse)) ){ if(! (curcon=ClientLogin(jrequest,jresponse)) ){ Loading @@ -461,8 +469,6 @@ namespace authdb { size_t outsize=0; const char *out=json_object_to_json_string_length(jresponse,0,&outsize); std::cout << out << std::endl; rep.setState(HTTP200); rep.setContentType("text/json"); rep.send(curreq,out,outsize); Loading