Loading src/authdb.cpp +45 −0 Original line number Diff line number Diff line Loading @@ -336,6 +336,51 @@ namespace authdb { return; } // Handle "admin" as special domain → use _AdminBackend directly if(strcmp(domain,"admin")==0){ if(_AdminBackend.end() > sizeof(authdb::AuthHeader)){ ::uuid::uuid adminDid; for(int _retry=0; _retry<5; ++_retry){ try{ AuthBackend::Guard guard(_AdminBackend, AuthBackend::Shared); ApiController(_AdminBackend,adminDid,curreq,tid,args); g_Log.access(clientAddr,method,curreq.getRequestURL(),200); break; }catch(AuthBackendError &e){ if(_retry<4){ std::this_thread::sleep_for(std::chrono::milliseconds(100)); continue; } g_Log.error(clientAddr,e.what()); g_Log.access(clientAddr,method,curreq.getRequestURL(),500); json_object *jerr = json_object_new_array(); json_object *eobj = json_object_new_object(); json_object_object_add(eobj,"error",json_object_new_string(e.what())); json_object_array_add(jerr,eobj); const char *errstr = json_object_to_json_string(jerr); libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("application/json"); rep.send(curreq,errstr,strlen(errstr)); json_object_put(jerr); }catch(std::exception &e){ g_Log.error(clientAddr,e.what()); libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("application/json"); rep.send(curreq,"[{\"error\":\"internal error\"}]",28); break; } } } else { libhttppp::HttpResponse rep; rep.setState(HTTP503); rep.setContentType("application/json"); rep.send(curreq,"[{\"error\":\"not initialized\"}]",29); } return; } ::uuid::uuid did; if(did.parse(domain)!=0){ Loading Loading
src/authdb.cpp +45 −0 Original line number Diff line number Diff line Loading @@ -336,6 +336,51 @@ namespace authdb { return; } // Handle "admin" as special domain → use _AdminBackend directly if(strcmp(domain,"admin")==0){ if(_AdminBackend.end() > sizeof(authdb::AuthHeader)){ ::uuid::uuid adminDid; for(int _retry=0; _retry<5; ++_retry){ try{ AuthBackend::Guard guard(_AdminBackend, AuthBackend::Shared); ApiController(_AdminBackend,adminDid,curreq,tid,args); g_Log.access(clientAddr,method,curreq.getRequestURL(),200); break; }catch(AuthBackendError &e){ if(_retry<4){ std::this_thread::sleep_for(std::chrono::milliseconds(100)); continue; } g_Log.error(clientAddr,e.what()); g_Log.access(clientAddr,method,curreq.getRequestURL(),500); json_object *jerr = json_object_new_array(); json_object *eobj = json_object_new_object(); json_object_object_add(eobj,"error",json_object_new_string(e.what())); json_object_array_add(jerr,eobj); const char *errstr = json_object_to_json_string(jerr); libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("application/json"); rep.send(curreq,errstr,strlen(errstr)); json_object_put(jerr); }catch(std::exception &e){ g_Log.error(clientAddr,e.what()); libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("application/json"); rep.send(curreq,"[{\"error\":\"internal error\"}]",28); break; } } } else { libhttppp::HttpResponse rep; rep.setState(HTTP503); rep.setContentType("application/json"); rep.send(curreq,"[{\"error\":\"not initialized\"}]",29); } return; } ::uuid::uuid did; if(did.parse(domain)!=0){ Loading