Commit 053c3ffb authored by jan.koester's avatar jan.koester
Browse files

some changes

parent dae3ac76
Loading
Loading
Loading
Loading
Loading
+2 −1
Changes for src/admin.cpp: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2647,10 +2647,11 @@ URLNOTFOUND:
    };

    AdminInterface::AdminInterface(AuthBackend &bck,Session &session,netplus::socket *ssock) : _bck(bck), _session(session) {
        _ctl = std::make_shared<AdminController>(bck,session,ssock);
        _ctl =new AdminController(bck,session,ssock);
    }

    AdminInterface::~AdminInterface(){
        delete _ctl;
    }

    void AdminInterface::Request(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
+1 −3
Changes for src/admin.h: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include <memory>

#include <httppp/http.h>

#include "backend.h"
@@ -43,7 +41,7 @@ namespace authdb {
        ~AdminInterface();
        void Request(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args);
    public:
        std::shared_ptr<AdminController>  _ctl;
        AdminController                            * _ctl;
        AuthBackend                                 &_bck;
        Session                                          &_session;
    };
+13 −5
Changes for src/api.cpp: 13 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@ namespace authdb {
                                for(int ii =0; ii<ocount; ++ii) {
                                    json_object_object_foreach(val,okey,oval){
                                        if(strcmp(okey,type)==0){
                                                if( strcmp(json_object_get_string(oval),"client")!=0 || strcmp(json_object_get_string(oval),"user")!=0 )
                                                if( strcmp(json_object_get_string(oval),"client")!=0 ||
                                                    strcmp(json_object_get_string(oval),"user")!=0 )
                                                    continue;
                                        }else if(strcmp(okey,"name")==0){
                                                name=json_object_get_string(oval);
@@ -136,7 +137,7 @@ namespace authdb {

                                            if(name==cdat.getName() ){
                                                if(pwsalt==cdat.getKey() ){
                                                    uuid cid=clt.addConnection();
                                                    uuid cid=clt.addConnection(*_Backend,cdat);
                                                    json_object *respid=json_object_new_object();
                                                    json_object_object_add(respid,"connectionid",json_object_new_string(cid.c_str()));
                                                    json_object_array_add(response,respid);
@@ -157,7 +158,12 @@ namespace authdb {

            std::vector<char> recv;

            std::copy(curreq->RecvData.begin(),curreq->RecvData.end(),std::back_inserter(recv));
            if(curreq->getContentLength() <=curreq->RecvData.size())
                std::copy(curreq->RecvData.begin(),curreq->RecvData.begin()+curreq->getContentLength(),
                          std::back_inserter(recv));
            else
                throw AuthBackendError("get no data input!");


            recv.push_back('\0');

@@ -177,9 +183,11 @@ namespace authdb {

            char cdid[sizeof(uuid_t)];
            sscanf(curreq->getRequestURL(),"/api/%[^/]",cdid);
            uuid did;

            uuid_parse(cdid,did.value);
            std::cout << cdid << std::endl;

            uuid did(cdid);


            if(!clientLogin(did, jrequest,jresponse)){
                const char *ret=json_object_to_json_string(jresponse);
+8 −3
Changes for src/backend.cpp: 8 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -30,20 +30,25 @@
#include "backend.h"

authdb::AuthBackend::AuthBackend(int type, const char* options,const char *domain) : _Type(type),_Options(options),_Domain(domain) {
    _Type=type;
    if(_Type==AuthBackendType::File){
        _Api = std::make_shared<class File>(_Options,VERSION,_Domain);
        _Api =  new class File(_Options,VERSION,_Domain);
    }else{
        throw AuthBackendError("unkown file backend");
    }
}

authdb::AuthBackend::AuthBackend(const AuthBackend &backend){
    if(backend._Type==AuthBackendType::File){
        _Api = std::make_shared<class File>(backend._Options,VERSION,backend._Domain);
     _Type=backend._Type;
    if(_Type==AuthBackendType::File){
        _Api = new class File(backend._Options,VERSION,backend._Domain);
    }
}

authdb::AuthBackend::~AuthBackend(){
        if(_Type==AuthBackendType::File){
            delete (class File*) _Api;
        }
}

void authdb::AuthBackend::read(char unsigned *src,size_t srcsize){
+1 −2
Changes for src/backend.h: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include <memory>
#include <stdexcept>

#pragma once
@@ -77,7 +76,7 @@ namespace authdb{
        void read(char unsigned *src,size_t srcsize);
    private:
        int                                  _Type;
        std::shared_ptr<AuthBackendApi> _Api;
        AuthBackendApi           *_Api;
        const char                     *_Options;
        const char                     *_Domain;
    };
Loading