From 2a3677f767c1bd5a04e412a3f133bdcebdfef432 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 17 Jun 2021 11:59:31 +0200 Subject: [PATCH] little things --- .../src/cpp/JSONInterface/JsonResetPassword.cpp | 10 ++++++---- .../src/cpp/JSONInterface/JsonUpdateUserInfos.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/login_server/src/cpp/JSONInterface/JsonResetPassword.cpp b/login_server/src/cpp/JSONInterface/JsonResetPassword.cpp index ac1606ab5..f06459baf 100644 --- a/login_server/src/cpp/JSONInterface/JsonResetPassword.cpp +++ b/login_server/src/cpp/JSONInterface/JsonResetPassword.cpp @@ -42,10 +42,12 @@ Poco::JSON::Object* JsonResetPassword::handle(Poco::Dynamic::Var params) return stateError("password encryption is already running"); } - user->setNewPassword(password); - KeyPairEd25519* key_pair = NULL; - if (!user->tryLoadPassphraseUserBackup(&key_pair)) { - user->setGradidoKeyPair(key_pair); + auto update_password_result = user->setNewPassword(password); + if (update_password_result == 2) { + KeyPairEd25519* key_pair = NULL; + if (!user->tryLoadPassphraseUserBackup(&key_pair)) { + user->setGradidoKeyPair(key_pair); + } } return stateSuccess(); } \ No newline at end of file diff --git a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp index 86e79372d..bbec11110 100644 --- a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp +++ b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp @@ -171,8 +171,10 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) if (str_val.size() > 0) { - - if (!user->hasPassword() || isOldPasswordValid(updates, jsonErrorsArray)) + if (!user->hasPassword()) { + return stateError("login state invalid"); + } + if (isOldPasswordValid(updates, jsonErrorsArray)) { NotificationList errors; if (!sm->checkPwdValidation(value.toString(), &errors, LanguageManager::getInstance()->getFreeCatalog(LANG_EN))) {