Loading src/api.cpp +40 −4 Changes for src/api.cpp: 40 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -406,11 +406,47 @@ namespace authdb { for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) { if(strcmp(key,"changeuserpw")==0){ uuid tmp; tmp.parse(json_object_get_string(val)); AuthSession.remSession(tmp); int ocount = json_object_object_length(val); std::string oldpw,newpw; for(int ii =0; ii<ocount; ++ii) { json_object_object_foreach(val,okey,oval){ if(strcmp(okey,"oldpw")==0){ oldpw=json_object_get_string(oval); }else if( strcmp(okey,"newpw")==0){ newpw=json_object_get_string(oval); } } } std::string oldhash,newhash; sha512 sha; sha.hash(oldpw,oldhash); sha.hash(newpw,newhash); uuid uid; _SessionData->getUid(uid); class UserData udat(uid.value); User user; size_t ustart=0; user.info(_Backend,udat,ustart); if(newhash!=oldhash || oldhash != udat.getPwHash() ){ json_object *slogoff=json_object_new_object(); json_object_object_add(slogoff,"remsession", json_object_new_string(tmp.c_str())); json_object_object_add(slogoff,"changeuserpw", json_object_new_boolean(false)); json_object_array_add(response,slogoff); } udat.setPwHash(newhash.c_str()); ustart=0; 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_array_add(response,slogoff); return; } Loading Loading
src/api.cpp +40 −4 Changes for src/api.cpp: 40 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -406,11 +406,47 @@ namespace authdb { for(int i =0; i<fcount; ++i) { json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) { if(strcmp(key,"changeuserpw")==0){ uuid tmp; tmp.parse(json_object_get_string(val)); AuthSession.remSession(tmp); int ocount = json_object_object_length(val); std::string oldpw,newpw; for(int ii =0; ii<ocount; ++ii) { json_object_object_foreach(val,okey,oval){ if(strcmp(okey,"oldpw")==0){ oldpw=json_object_get_string(oval); }else if( strcmp(okey,"newpw")==0){ newpw=json_object_get_string(oval); } } } std::string oldhash,newhash; sha512 sha; sha.hash(oldpw,oldhash); sha.hash(newpw,newhash); uuid uid; _SessionData->getUid(uid); class UserData udat(uid.value); User user; size_t ustart=0; user.info(_Backend,udat,ustart); if(newhash!=oldhash || oldhash != udat.getPwHash() ){ json_object *slogoff=json_object_new_object(); json_object_object_add(slogoff,"remsession", json_object_new_string(tmp.c_str())); json_object_object_add(slogoff,"changeuserpw", json_object_new_boolean(false)); json_object_array_add(response,slogoff); } udat.setPwHash(newhash.c_str()); ustart=0; 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_array_add(response,slogoff); return; } Loading