Commit 93924567 authored by jan.koester's avatar jan.koester
Browse files

pwchange is working

parent 8d794fe0
Loading
Loading
Loading
Loading
Loading
+2 −5
Changes for client/client.cpp: 2 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ bool authdb::client::Client::remSession(){
    json_tokener_free(jtok);
    return false;
}
#include <iostream>

void authdb::client::Client::changeUserPw(const std::string& oldpw,const std::string& newpw){
    json_object *jresponse = json_object_new_object();
    json_object *cmd=json_object_new_array();
@@ -324,13 +324,12 @@ void authdb::client::Client::changeUserPw(const std::string& oldpw,const std::st
    json_object *pchange=json_object_new_object();

    json_object_object_add(obj,"usersession", json_object_new_string(_Con.getSessionID().c_str()));
    json_object_object_add(obj,"changeuserpw", pchange);

    json_object_set_string(pchange,"changeuserpw");
    json_object_object_add(pchange,"oldpw",json_object_new_string(oldpw.c_str()));
    json_object_object_add(pchange,"newpw",json_object_new_string(newpw.c_str()));

    json_object_array_add(cmd,obj);
    json_object_array_add(cmd,pchange);
    json_object_object_add(jresponse,"commands",cmd);

    size_t outsize=0;
@@ -343,6 +342,4 @@ void authdb::client::Client::changeUserPw(const std::string& oldpw,const std::st
    std::vector<char> resp(_Con._Client->Post(_Con._Url.getPath(),"text/json",out));

    resp.push_back('\0');

    std::cout << resp.data() << std::endl;
}
+7 −5
Changes for src/api.cpp: 7 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -429,21 +429,22 @@ namespace authdb {
                        class UserData udat(uid.value);

                        User user;
                        size_t ustart=0;
                        size_t ustart=sizeof(AuthHeader);
                        user.info(_Backend,udat,ustart);

                        if(newhash!=oldhash || oldhash == udat.getPwHash() ){
                        if(newhash==oldhash || oldhash != udat.getPwHash() ){
                            json_object *slogoff=json_object_new_object();
                            json_object_object_add(slogoff,"changeuserpw", json_object_new_boolean(false));
                            json_object_array_add(response,slogoff);
                            return;
                        }

                        udat.setPwHash(newhash.c_str());
                        ustart=0;
                        ustart=sizeof(AuthHeader);
                        user.edit(_Backend,udat,ustart);

                        json_object *slogoff=json_object_new_object();
                        json_object_object_add(slogoff,"remsession", json_object_new_boolean(true));
                        json_object_object_add(slogoff,"changeuserpw", json_object_new_boolean(true));
                        json_object_array_add(response,slogoff);
                        return;
                    }
@@ -503,6 +504,7 @@ namespace authdb {
            Connection(jrequest,jresponse);
            SessionInfo(jrequest,jresponse);
            remSession(jrequest,jresponse);
            changeUserPw(jrequest,jresponse);

            if(! (curcon=checkConnection(jrequest,jresponse)) ){
                if(! (curcon=ClientLogin(jrequest,jresponse)) ){
@@ -517,7 +519,7 @@ namespace authdb {
            }

            if(_SessionData){
                changeUserPw(jrequest,jresponse);

                checkGPO(jrequest,jresponse);
            }

+2 −0
Changes for src/user.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -155,6 +155,8 @@ bool authdb::User::exits(AuthBackend& backend, uuid_t* uid, const char* name,int


void authdb::User::edit(AuthBackend &backend,class UserData& dat, size_t &pos){
    remove(backend,dat.uid);
    create(backend,&dat);
}

void authdb::User::remove(AuthBackend &backend,const uuid_t uid){