From e804aa655c8db2a40cfd05259fba3d53312adb33 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 8 Jun 2021 17:01:36 +0200 Subject: [PATCH 01/26] Feature: Cange Username --- frontend/src/apis/loginAPI.js | 6 ++- .../UserProfile/UserCard_FormUsername.vue | 37 +++++++++++++------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 91e92a2cc..3ba7b576a 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -120,12 +120,14 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) }, - changeUsernameProfile: async (sessionId, email, usernameNew) => { + changeUsernameProfile: async (sessionId, email, username) => { + console.log('changeUsernameProfile', username) + const payload = { session_id: sessionId, email, update: { - 'User.usernameNew': usernameNew, + 'User.username': username, }, } return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue index b195f6ef6..7e6b67df6 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue @@ -3,11 +3,11 @@ - + {{ $t('form.username') }} {{ $t('form.change') }}
- + {{ $t('form.cancel') }} @@ -20,16 +20,16 @@ {{ $t('form.username') }} - @{{ $store.state.username }} + @{{ username }} - - - + + +
{{ $t('form.change_username_info') }}
- + {{ $t('form.save') }}
@@ -47,16 +47,29 @@ export default { name: 'FormUsername', data() { return { - edit_username: true, - username: '', + editUsername: true, + username: this.$store.state.username, + form: { + username: this.$store.state.username, + }, } }, + props: { + UserProfileTestData: { type: Object }, + }, methods: { async onSubmit() { - // console.log(this.data) - const result = await loginAPI.changeUsernameProfile(this.username) + console.log('onSubmit', this.form.username) + const result = await loginAPI.changeUsernameProfile( + this.$store.state.sessionId, + this.$store.state.email, + { + username: this.form.username, + }, + ) if (result.success) { - alert('changeUsername success') + this.$store.commit('username', this.form.username) + this.editUserdata = true } else { alert(result.result.message) } From a7009f935db0dcbfa10823a8836ba1469ef97510 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 8 Jun 2021 17:09:40 +0200 Subject: [PATCH 02/26] change api caall --- .../src/views/Pages/UserProfile/UserCard_FormUsername.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue index 7e6b67df6..371d6a2e9 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue @@ -62,10 +62,8 @@ export default { console.log('onSubmit', this.form.username) const result = await loginAPI.changeUsernameProfile( this.$store.state.sessionId, - this.$store.state.email, - { - username: this.form.username, - }, + this.$store.state.email, + this.form.username, ) if (result.success) { this.$store.commit('username', this.form.username) From 519d5fec2f84624de5efa08c0b1d4707003f6a09 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 9 Jun 2021 10:21:58 +0200 Subject: [PATCH 03/26] username change and save --- frontend/src/apis/loginAPI.js | 2 - .../UserProfile/UserCard_FormUsername.vue | 62 ++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 3ba7b576a..2eeec754e 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -121,8 +121,6 @@ const loginAPI = { return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) }, changeUsernameProfile: async (sessionId, email, username) => { - console.log('changeUsernameProfile', username) - const payload = { session_id: sessionId, email, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue index 371d6a2e9..445c69f8e 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue @@ -1,42 +1,58 @@ @@ -59,15 +75,15 @@ export default { }, methods: { async onSubmit() { - console.log('onSubmit', this.form.username) const result = await loginAPI.changeUsernameProfile( this.$store.state.sessionId, - this.$store.state.email, + this.$store.state.email, this.form.username, ) if (result.success) { this.$store.commit('username', this.form.username) - this.editUserdata = true + this.editUserdata = this.editUsername = !this.editUsername + alert('Dein Username wurde geändert.') } else { alert(result.result.message) } From 7ea10b0c5dd6ed36ec29c62c36c0e9cb9ba0efbd Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 9 Jun 2021 10:55:55 +0200 Subject: [PATCH 04/26] change userdata css style --- .../UserProfile/UserCard_FormUserData.vue | 114 ++++++++++-------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index a1f6a5919..79e8df37b 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -6,59 +6,72 @@ style="background-color: #ebebeba3 !important" > - - -
- {{ $t('form.edit') }} - - + + + + {{ $t('form.change') }} + + + + + + + + + + + {{ $t('form.firstname') }} + + + {{ form.firstName }} + + + + + + + + {{ $t('form.lastname') }} + + + {{ form.lastName }} + + + + + + + + {{ $t('form.description') }} + + + {{ form.description }} + + + -
- - - {{ $t('form.firstname') }} - - - {{ form.firstName }} - - - - - - - - {{ $t('form.lastname') }} - - - {{ form.lastName }} - - - - - - - - {{ $t('form.description') }} - - - {{ form.description }} - - - - - -
+ + +
+ + {{ $t('form.save') }} + +
+
+
@@ -98,6 +111,7 @@ export default { this.$store.commit('lastName', this.form.lastName) this.$store.commit('description', this.form.description) this.editUserdata = true + alert('Deine Daten wurden gespeichert und sind geändert.') } else { alert(result.result.message) } From e2edeaca2bd92585e24fc49c05f55f318a4d8bb6 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 9 Jun 2021 20:45:59 +0200 Subject: [PATCH 05/26] try a php coverage report script --- .github/workflows/test.yml | 6 ++++-- community_server/Dockerfile | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bd99e045..f7a9a22bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -335,12 +335,14 @@ jobs: ######################################################################### # COVERAGE CHECK BACKEND COMMUNITY-SERVER #################################### ########################################################################## - #- name: backend community simplecov | Coverage check + - name: backend community simplecov | Coverage check + run: | + docker run -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test vendor/bin/coverage-check ./webroot/coverage/clover.xml 5 # uses: webcraftmedia/coverage-check-action@master # with: # report_name: Coverage Backend # type: simplecov - # result_path: ./coverage/coverage.info + # result_path: ./coverage/clover.xml # min_coverage: 8 # token: ${{ github.token }} diff --git a/community_server/Dockerfile b/community_server/Dockerfile index eabb37741..596c4c98d 100644 --- a/community_server/Dockerfile +++ b/community_server/Dockerfile @@ -21,9 +21,9 @@ RUN apt-get update \ && apt-get -y --no-install-recommends install php7.4-xdebug \ && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -WORKDIR /var/www/cakephp + ENV XDEBUG_MODE=coverage +RUN composer require --dev rregeer/phpunit-coverage-check -CMD ./vendor/bin/phpunit --coverage-text=./webroot/coverage/coverage.info - +CMD ./vendor/bin/phpunit --coverage-clover=./webroot/coverage/clover.xml From bea597268fc1acc3d34dbf591cab92311a4eb9c3 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 9 Jun 2021 21:02:19 +0200 Subject: [PATCH 06/26] update name and target coverage --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 774467922..4f3d6a28c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -268,7 +268,7 @@ jobs: report_name: Coverage Backend type: lcov result_path: ./coverage/coverage.info - min_coverage: 6 + min_coverage: 13 token: ${{ github.token }} ############################################################################## @@ -335,9 +335,9 @@ jobs: ######################################################################### # COVERAGE CHECK BACKEND COMMUNITY-SERVER #################################### ########################################################################## - - name: backend community simplecov | Coverage check + - name: backend community | Coverage check run: | - docker run -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test vendor/bin/coverage-check ./webroot/coverage/clover.xml 5 + docker run -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test vendor/bin/coverage-check ./webroot/coverage/clover.xml 14 # uses: webcraftmedia/coverage-check-action@master # with: # report_name: Coverage Backend From f88ddbbf1c626899ecb4a9f7447c909ce600a1b3 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 10 Jun 2021 09:58:08 +0200 Subject: [PATCH 07/26] update string validation - move it in extra function to have less code copies - fix bug which return no error messag if input was an array instead of a string --- .../cpp/JSONInterface/JsonUpdateUserInfos.cpp | 94 +++++++++++-------- .../cpp/JSONInterface/JsonUpdateUserInfos.h | 2 + 2 files changed, 58 insertions(+), 38 deletions(-) diff --git a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp index 7db31df33..40d5dd016 100644 --- a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp +++ b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp @@ -68,49 +68,46 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) try { - if ( "User.first_name" == name && value.size() > 0) { - if (!value.isString()) { - jsonErrorsArray.add("User.first_name isn't a string"); - } - else { - user_model->setFirstName(value.toString()); + if ( "User.first_name" == name) { + std::string str_val = validateString(value, "User.first_name", jsonErrorsArray); + + if (str_val.size() > 0) { + user_model->setFirstName(str_val); extractet_values++; } } - else if ("User.last_name" == name && value.size() > 0) { - if (!value.isString()) { - jsonErrorsArray.add("User.last_name isn't a string"); - } - else { - user_model->setLastName(value.toString()); + else if ("User.last_name" == name ) { + std::string str_val = validateString(value, "User.last_name", jsonErrorsArray); + + if (str_val.size() > 0) { + user_model->setLastName(str_val); extractet_values++; } + } - else if ("User.username" == name && value.size() > 3) { - if (!value.isString()) { - jsonErrorsArray.add("User.username isn't a string"); - } - else { - auto new_username = value.toString(); - if (user_model->getUsername() != new_username) { - if (user->isUsernameAlreadyUsed(new_username)) { + else if ("User.username" == name) { + std::string str_val = validateString(value, "User.username", jsonErrorsArray); + + if (str_val.size() > 0) { + if (user_model->getUsername() != str_val) { + if (user->isUsernameAlreadyUsed(str_val)) { jsonErrorsArray.add("username already used"); } else { - user_model->setUsername(new_username); + user_model->setUsername(str_val); extractet_values++; } } } } - else if ("User.description" == name && value.size() > 3) { - if (!value.isString()) { - jsonErrorsArray.add("description isn't a string"); - } - else { - user_model->setDescription(value.toString()); + else if ("User.description" == name) { + std::string str_val = validateString(value, "User.description", jsonErrorsArray); + + if (str_val.size() > 0) { + user_model->setDescription(str_val); extractet_values++; } + } else if ("User.disabled" == name) { if (value.isBoolean()) { @@ -130,11 +127,10 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) } } else if ("User.language" == name && value.size() > 0) { - if (!value.isString()) { - jsonErrorsArray.add("User.language isn't a string"); - } - else { - auto lang = LanguageManager::languageFromString(value.toString()); + std::string str_val = validateString(value, "User.language", jsonErrorsArray); + + if (str_val.size() > 0) { + auto lang = LanguageManager::languageFromString(str_val); if (LANG_NULL == lang) { jsonErrorsArray.add("User.language isn't a valid language"); } @@ -143,12 +139,13 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) extractet_values++; } } + } - else if ("User.password" == name && value.size() > 0 && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_PASSWORD_REQUESTS) == ServerConfig::UNSECURE_PASSWORD_REQUESTS) { - if (!value.isString()) { - jsonErrorsArray.add("User.password isn't string"); - } - else { + else if ("User.password" == name && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_PASSWORD_REQUESTS) == ServerConfig::UNSECURE_PASSWORD_REQUESTS) { + std::string str_val = validateString(value, "User.password", jsonErrorsArray); + + if (str_val.size() > 0) { + NotificationList errors; if (!sm->checkPwdValidation(value.toString(), &errors, LanguageManager::getInstance()->getFreeCatalog(LANG_EN))) { jsonErrorsArray.add("User.password isn't valid"); @@ -174,7 +171,9 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) } } catch (Poco::Exception& ex) { - jsonErrorsArray.add("update parameter invalid"); + std::string error_message = "exception by parsing json: "; + error_message += ex.displayText(); + jsonErrorsArray.add(error_message); } } if (extractet_values > 0) { @@ -189,4 +188,23 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) result->set("state", "success"); return result; +} + +std::string JsonUpdateUserInfos::validateString(Poco::Dynamic::Var value, const char* fieldName, Poco::JSON::Array& errorArray) +{ + std::string errorMessage = fieldName; + + if (!value.isString()) { + errorMessage += " isn't a string"; + errorArray.add(errorMessage); + return ""; + } + std::string string_value = value.toString(); + + if (string_value.size() == 0) { + errorMessage += " is empty"; + errorArray.add(errorArray); + return ""; + } + return string_value; } \ No newline at end of file diff --git a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.h b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.h index 2c1ca94fc..f651fb345 100644 --- a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.h +++ b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.h @@ -18,6 +18,8 @@ public: protected: + std::string validateString(Poco::Dynamic::Var value, const char* fieldName, Poco::JSON::Array& errorArray); + }; From a21e88ac94175d780d68378451f23b2b040e3a2a Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 10 Jun 2021 15:53:27 +0200 Subject: [PATCH 08/26] fix profil page bugs --- .../src/views/Layout/DashboardLayout_gdd.vue | 37 ++-- .../UserProfile/UserCard_FormUserData.vue | 106 ++++++----- .../UserProfile/UserCard_FormUserPasswort.vue | 169 ++++++++++++------ .../UserProfile/UserCard_FormUsername.vue | 5 +- 4 files changed, 202 insertions(+), 115 deletions(-) diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index 70a35a40a..ce4d29768 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -2,24 +2,25 @@
diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index 79e8df37b..3bb1c48ae 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -12,7 +12,7 @@ v-if="editUserdata" @click="editUserdata = !editUserdata" class="pointer" - icon="gear-fill" + icon="pencil" > {{ $t('form.change') }} @@ -29,49 +29,57 @@ - - - {{ $t('form.firstname') }} - - - {{ form.firstName }} - - - - - - - - {{ $t('form.lastname') }} - - - {{ form.lastName }} - - - - - - - - {{ $t('form.description') }} - - - {{ form.description }} - - - - - + + + + {{ $t('form.firstname') }} + + + {{ form.firstName }} + + + + + + + + {{ $t('form.lastname') }} + + + {{ form.lastName }} + + + + + + + + {{ $t('form.description') }} + + + {{ form.description }} + + + + + - - -
- - {{ $t('form.save') }} - -
-
-
+ + +
+ + {{ $t('form.save') }} + +
+
+
+
@@ -93,9 +101,21 @@ export default { lastName: this.$store.state.lastName, description: this.$store.state.description, }, + loading: true, } }, methods: { + loadSubmitButton() { + if ( + this.form.firstName !== this.$store.state.firstName || + this.form.lastName !== this.$store.state.lastName || + this.form.description !== this.$store.state.description + ) { + this.loading = false + } else { + this.loading = true + } + }, async onSubmit() { const result = await loginAPI.updateUserInfos( this.$store.state.sessionId, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue index e1ade4ae0..6bc1d8942 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue @@ -1,62 +1,105 @@ @@ -71,10 +114,30 @@ export default { email: null, password: '', passwordNew: '', - passwordNew2: '', + passwordNewRepeat: '', + passwordVisibleOldPwd: false, + passwordVisibleNewPwd: false, + passwordVisibleNewPwdRepeat: false, + loading: true, } }, methods: { + togglePasswordVisibilityNewPwd() { + this.passwordVisibleNewPwd = !this.passwordVisibleNewPwd + }, + togglePasswordVisibilityNewPwdRepeat() { + this.passwordVisibleNewPwdRepeat = !this.passwordVisibleNewPwdRepeat + }, + togglePasswordVisibilityOldPwd() { + this.passwordVisibleOldPwd = !this.passwordVisibleOldPwd + }, + loadSubmitButton() { + if (this.passwordVisibleNewPwd === this.passwordVisibleNewPwdRepeat) { + this.loading = false + } else { + this.loading = true + } + }, async onSubmit() { // console.log(this.data) const result = await loginAPI.changePasswordProfile( diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue index 445c69f8e..38738e54a 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue @@ -7,7 +7,7 @@ v-if="editUsername" @click="editUsername = !editUsername" class="pointer" - icon="gear-fill" + icon="pencil" > {{ $t('form.change') }} @@ -32,6 +32,9 @@ + + {{ $t('form.username') }} + From ddb4ba676ba0450655d575036f75c1fd0aecbcfb Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Jun 2021 16:45:28 +0200 Subject: [PATCH 09/26] try to implement toasters --- frontend/package.json | 1 + frontend/src/plugins/dashboard-plugin.js | 3 +- frontend/src/views/Pages/ForgotPassword.vue | 47 +++--- frontend/src/views/Pages/ResetPassword.vue | 156 ++++++++++---------- 4 files changed, 108 insertions(+), 99 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 34ce37b76..2a41bea56 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -51,6 +51,7 @@ "nouislider": "^12.1.0", "particles-bg-vue": "1.2.3", "perfect-scrollbar": "^1.3.0", + "portal-vue": "^2.1.7", "prettier": "^2.2.1", "qrcode": "^1.4.4", "quill": "^1.3.6", diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index b7c0ea06c..aa4bf200f 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -12,7 +12,7 @@ import GlobalDirectives from './globalDirectives' import SideBar from '@/components/SidebarPlugin' // vue-bootstrap -import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' +import { BootstrapVue, IconsPlugin, ToastPlugin } from 'bootstrap-vue' // asset imports import '@/assets/scss/argon.scss' @@ -49,6 +49,7 @@ export default { Vue.use(Notifications) Vue.use(BootstrapVue) Vue.use(IconsPlugin) + Vue.use(ToastPlugin) Vue.use(VueGoodTablePlugin) Vue.use(VueMoment) Vue.use(VueQrcodeReader) diff --git a/frontend/src/views/Pages/ForgotPassword.vue b/frontend/src/views/Pages/ForgotPassword.vue index 32331d080..ecbd870c3 100644 --- a/frontend/src/views/Pages/ForgotPassword.vue +++ b/frontend/src/views/Pages/ForgotPassword.vue @@ -46,28 +46,31 @@
diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 99892612c..29aa015d9 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -85,82 +85,86 @@ From 0978b3e627d99871bb4ca9d0393c3f351275764b Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 10 Jun 2021 17:45:23 +0200 Subject: [PATCH 10/26] fix lint --- .../src/views/Layout/DashboardLayout_gdd.vue | 38 +++++++++---------- .../UserProfile/UserCard_FormUserData.vue | 6 +-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index ce4d29768..564b4e430 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -2,25 +2,25 @@
diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index 3bb1c48ae..e07313c96 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -35,7 +35,7 @@ {{ $t('form.firstname') }} - {{ form.firstName }} + {{ $store.state.firstName }} @@ -46,7 +46,7 @@ {{ $t('form.lastname') }} - {{ form.lastName }} + {{ $store.state.lastName }} @@ -57,7 +57,7 @@ {{ $t('form.description') }} - {{ form.description }} + {{ $store.state.description }} From 552b31f77a451247f983a271c6db02413de733e2 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Jun 2021 18:04:48 +0200 Subject: [PATCH 11/26] trying to fix the scss --- frontend/src/assets/scss/argon.scss | 107 ++++++++++---- frontend/src/plugins/dashboard-plugin.js | 3 + frontend/src/views/Pages/ForgotPassword.vue | 50 +++---- frontend/src/views/Pages/ResetPassword.vue | 152 ++++++++++---------- 4 files changed, 186 insertions(+), 126 deletions(-) diff --git a/frontend/src/assets/scss/argon.scss b/frontend/src/assets/scss/argon.scss index 01a002691..1fa663a5f 100644 --- a/frontend/src/assets/scss/argon.scss +++ b/frontend/src/assets/scss/argon.scss @@ -23,38 +23,95 @@ // Bootstrap (4.1.3) components -@import "~bootstrap/scss/root"; -@import "~bootstrap/scss/reboot"; -@import "~bootstrap/scss/type"; -@import "~bootstrap/scss/images"; -@import "~bootstrap/scss/code"; -@import "~bootstrap/scss/grid"; -@import "~bootstrap/scss/tables"; -@import "~bootstrap/scss/forms"; -@import "~bootstrap/scss/buttons"; -@import "~bootstrap/scss/transitions"; -@import "~bootstrap/scss/dropdown"; +@import "~bootstrap/scss/alert"; +@import "~bootstrap/scss/badge"; +@import "~bootstrap/scss/breadcrumb"; @import "~bootstrap/scss/button-group"; -@import "~bootstrap/scss/input-group"; +@import "~bootstrap/scss/buttons"; +@import "~bootstrap/scss/card"; +@import "~bootstrap/scss/carousel"; +@import "~bootstrap/scss/close"; +@import "~bootstrap/scss/code"; @import "~bootstrap/scss/custom-forms"; +@import "~bootstrap/scss/dropdown"; +@import "~bootstrap/scss/forms"; +@import "~bootstrap/scss/grid"; +@import "~bootstrap/scss/images"; +@import "~bootstrap/scss/input-group"; +@import "~bootstrap/scss/jumbotron"; +@import "~bootstrap/scss/list-group"; +@import "~bootstrap/scss/media"; +@import "~bootstrap/scss/modal"; @import "~bootstrap/scss/nav"; @import "~bootstrap/scss/navbar"; -@import "~bootstrap/scss/card"; -@import "~bootstrap/scss/breadcrumb"; @import "~bootstrap/scss/pagination"; -@import "~bootstrap/scss/badge"; -@import "~bootstrap/scss/jumbotron"; -@import "~bootstrap/scss/alert"; -@import "~bootstrap/scss/progress"; -@import "~bootstrap/scss/media"; -@import "~bootstrap/scss/list-group"; -@import "~bootstrap/scss/close"; -@import "~bootstrap/scss/modal"; -@import "~bootstrap/scss/tooltip"; @import "~bootstrap/scss/popover"; -@import "~bootstrap/scss/carousel"; -@import "~bootstrap/scss/utilities"; @import "~bootstrap/scss/print"; +@import "~bootstrap/scss/progress"; +@import "~bootstrap/scss/reboot"; +@import "~bootstrap/scss/root"; +@import "~bootstrap/scss/tables"; +@import "~bootstrap/scss/toasts"; +@import "~bootstrap/scss/tooltip"; +@import "~bootstrap/scss/transitions"; +@import "~bootstrap/scss/type"; +@import "~bootstrap/scss/utilities"; +@import "~bootstrap/scss/variables"; + +// Utilities + +@import "~bootstrap/scss/utilities/align"; +@import "~bootstrap/scss/utilities/background"; +@import "~bootstrap/scss/utilities/borders"; +@import "~bootstrap/scss/utilities/clearfix"; +@import "~bootstrap/scss/utilities/display"; +@import "~bootstrap/scss/utilities/embed"; +@import "~bootstrap/scss/utilities/flex"; +@import "~bootstrap/scss/utilities/float"; +@import "~bootstrap/scss/utilities/overflow"; +@import "~bootstrap/scss/utilities/position"; +@import "~bootstrap/scss/utilities/screenreaders"; +@import "~bootstrap/scss/utilities/shadows"; +@import "~bootstrap/scss/utilities/sizing"; +@import "~bootstrap/scss/utilities/spacing"; +@import "~bootstrap/scss/utilities/stretched-link"; +@import "~bootstrap/scss/utilities/text"; +@import "~bootstrap/scss/utilities/visibility"; + + +// Mixins + +@import "~bootstrap/scss/mixins/alert"; +@import "~bootstrap/scss/mixins/badge"; +@import "~bootstrap/scss/mixins/border-radius"; +@import "~bootstrap/scss/mixins/box-shadow"; +@import "~bootstrap/scss/mixins/breakpoints"; +@import "~bootstrap/scss/mixins/buttons"; +@import "~bootstrap/scss/mixins/caret"; +@import "~bootstrap/scss/mixins/clearfix"; +@import "~bootstrap/scss/mixins/deprecate"; +@import "~bootstrap/scss/mixins/float"; +@import "~bootstrap/scss/mixins/forms"; +@import "~bootstrap/scss/mixins/gradients"; +@import "~bootstrap/scss/mixins/grid-framework"; +@import "~bootstrap/scss/mixins/grid"; +@import "~bootstrap/scss/mixins/hover"; +@import "~bootstrap/scss/mixins/image"; +@import "~bootstrap/scss/mixins/list-group"; +@import "~bootstrap/scss/mixins/lists"; +@import "~bootstrap/scss/mixins/nav-divider"; +@import "~bootstrap/scss/mixins/pagination"; +@import "~bootstrap/scss/mixins/reset-text"; +@import "~bootstrap/scss/mixins/resize"; +@import "~bootstrap/scss/mixins/screen-reader"; +@import "~bootstrap/scss/mixins/size"; +@import "~bootstrap/scss/mixins/table-row"; +@import "~bootstrap/scss/mixins/text-emphasis"; +@import "~bootstrap/scss/mixins/text-hide"; +@import "~bootstrap/scss/mixins/text-truncate"; +@import "~bootstrap/scss/mixins/transition"; +@import "~bootstrap/scss/mixins/visibility"; + // Argon utilities and components diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index aa4bf200f..7b245ef23 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -11,6 +11,8 @@ import GlobalDirectives from './globalDirectives' // Sidebar on the right. Used as a local plugin in DashboardLayout.vue import SideBar from '@/components/SidebarPlugin' +import PortalVue from 'portal-vue' + // vue-bootstrap import { BootstrapVue, IconsPlugin, ToastPlugin } from 'bootstrap-vue' @@ -47,6 +49,7 @@ export default { Vue.use(GlobalDirectives) Vue.use(SideBar) Vue.use(Notifications) + Vue.use(PortalVue) Vue.use(BootstrapVue) Vue.use(IconsPlugin) Vue.use(ToastPlugin) diff --git a/frontend/src/views/Pages/ForgotPassword.vue b/frontend/src/views/Pages/ForgotPassword.vue index ecbd870c3..6e4ea422a 100644 --- a/frontend/src/views/Pages/ForgotPassword.vue +++ b/frontend/src/views/Pages/ForgotPassword.vue @@ -46,31 +46,31 @@
diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 29aa015d9..de8f8cad8 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -85,86 +85,86 @@
From 5ae484fcb88b3b0907eaf05169b7e475b4fde16a Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 11 Jun 2021 09:35:40 +0200 Subject: [PATCH 12/26] import VueBootstrapToasts test --- frontend/package.json | 1 + frontend/src/App.vue | 1 + frontend/src/plugins/dashboard-plugin.js | 6 ++++-- frontend/src/views/Pages/ForgotPassword.vue | 6 ++---- frontend/yarn.lock | 5 +++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 2a41bea56..910644e2c 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -59,6 +59,7 @@ "sweetalert2": "^9.5.4", "vee-validate": "^3.4.5", "vue": "^2.6.11", + "vue-bootstrap-toasts": "^1.0.7", "vue-bootstrap-typeahead": "^0.2.6", "vue-chartjs": "^3.5.0", "vue-cli-plugin-i18n": "^1.0.1", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a6613bec1..500a7b2e1 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -3,6 +3,7 @@
+
diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index 7b245ef23..013ded702 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -13,8 +13,10 @@ import SideBar from '@/components/SidebarPlugin' import PortalVue from 'portal-vue' +import VueBootstrapToasts from 'vue-bootstrap-toasts' + // vue-bootstrap -import { BootstrapVue, IconsPlugin, ToastPlugin } from 'bootstrap-vue' +import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' // asset imports import '@/assets/scss/argon.scss' @@ -52,7 +54,7 @@ export default { Vue.use(PortalVue) Vue.use(BootstrapVue) Vue.use(IconsPlugin) - Vue.use(ToastPlugin) + Vue.use(VueBootstrapToasts) Vue.use(VueGoodTablePlugin) Vue.use(VueMoment) Vue.use(VueQrcodeReader) diff --git a/frontend/src/views/Pages/ForgotPassword.vue b/frontend/src/views/Pages/ForgotPassword.vue index 6e4ea422a..37077064c 100644 --- a/frontend/src/views/Pages/ForgotPassword.vue +++ b/frontend/src/views/Pages/ForgotPassword.vue @@ -58,16 +58,14 @@ export default { }, } }, + created() {}, methods: { async onSubmit() { const result = await loginAPI.sendEmail(this.form.email) if (result.success) { this.$router.push('/thx/password') } else { - this.$bvToast.toast(result.result.message, { - title: this.$t('error.error'), - noAutoHide: true, - }) + this.$toast.success(this.$t('error.error')) } }, }, diff --git a/frontend/yarn.lock b/frontend/yarn.lock index a3a835813..65f3ff71d 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -13268,6 +13268,11 @@ vm-browserify@^1.0.1: resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== +vue-bootstrap-toasts@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/vue-bootstrap-toasts/-/vue-bootstrap-toasts-1.0.7.tgz#111c38855941e8eb0538e21f41c173e2af67dd53" + integrity sha512-JhurJOAwdNcINQ/QlT701sx0r447YTGpvtxtmZNC9pwDvEqp2I0Pyv15jS4neWwYHkA1gXB42nBsDRcWcj1hlg== + vue-bootstrap-typeahead@^0.2.6: version "0.2.6" resolved "https://registry.yarnpkg.com/vue-bootstrap-typeahead/-/vue-bootstrap-typeahead-0.2.6.tgz#8c1999a00bf4bf9fc906bae3a462482482cbc297" From a76a5066f502d35b853fd7fb9cb5dc73a094bd1a Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 11 Jun 2021 09:42:49 +0000 Subject: [PATCH 13/26] remove for check for target date in send coins request --- community_server/src/Controller/AppRequestsController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/community_server/src/Controller/AppRequestsController.php b/community_server/src/Controller/AppRequestsController.php index 6b744ff69..ff3314e94 100644 --- a/community_server/src/Controller/AppRequestsController.php +++ b/community_server/src/Controller/AppRequestsController.php @@ -152,10 +152,7 @@ class AppRequestsController extends AppController if($result !== true) { return $this->returnJson($result); } - $required_fields = $this->checkAndCopyRequiredFields(['target_date'], $params, $data); - if($required_fields !== true) { - return $this->returnJson($required_fields); - } + if(!isset($params['memo']) || strlen($params['memo']) < 5 || strlen($params['memo']) > 150) { return $this->returnJson(['state' => 'error', 'msg' => 'memo is not set or not in expected range [5;150]']); } From 3f50d14d222ba56598a7bf80bb77b12a37a24caf Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 11 Jun 2021 14:54:25 +0200 Subject: [PATCH 14/26] allow only one username change --- login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp index 40d5dd016..804d06987 100644 --- a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp +++ b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp @@ -89,7 +89,10 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params) std::string str_val = validateString(value, "User.username", jsonErrorsArray); if (str_val.size() > 0) { - if (user_model->getUsername() != str_val) { + if (user_model->getUsername() != "") { + jsonErrorsArray.add("change username currently not supported!"); + } + else if (user_model->getUsername() != str_val) { if (user->isUsernameAlreadyUsed(str_val)) { jsonErrorsArray.add("username already used"); } From 840729fb94f013a6f48563fb6faa4050f8827aa4 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 11 Jun 2021 15:34:19 +0200 Subject: [PATCH 15/26] compare with last transaction sended --- .../JSONInterface/JsonCreateTransaction.cpp | 7 ++++++ login_server/src/cpp/model/Session.cpp | 11 ++++++++ login_server/src/cpp/model/Session.h | 6 +++++ .../src/cpp/model/gradido/Transaction.cpp | 25 +++++++++++++++++++ .../src/cpp/model/gradido/Transaction.h | 2 ++ 5 files changed, 51 insertions(+) diff --git a/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp b/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp index 5478f78cf..96f5a13a6 100644 --- a/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp +++ b/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp @@ -140,6 +140,13 @@ Poco::JSON::Object* JsonCreateTransaction::transfer(Poco::Dynamic::Var params) try { auto transaction = model::gradido::Transaction::createTransfer(sender_user, target_pubkey, mTargetGroup, amount, mMemo, mBlockchainType); + if (mSession->lastTransactionTheSame(transaction)) { + return stateError("transaction are the same as the last (within 100 seconds)"); + } + else { + mSession->setLastTransaction(transaction); + } + if (mAutoSign) { Poco::JSON::Array errors; transaction->sign(sender_user); diff --git a/login_server/src/cpp/model/Session.cpp b/login_server/src/cpp/model/Session.cpp index f50fa87df..767f1acb3 100644 --- a/login_server/src/cpp/model/Session.cpp +++ b/login_server/src/cpp/model/Session.cpp @@ -919,6 +919,17 @@ bool Session::useOrGeneratePassphrase(const std::string& passphase) } */ +bool Session::lastTransactionTheSame(Poco::AutoPtr newTransaction) +{ + assert(!newTransaction.isNull()); + lock(); + if (mLastTransaction.isNull()) { + return false; + } + bool result = mLastTransaction->isTheSameTransaction(newTransaction); + unlock(); + return result; +} bool Session::generateKeys(bool savePrivkey, bool savePassphrase) { diff --git a/login_server/src/cpp/model/Session.h b/login_server/src/cpp/model/Session.h index 1607d23c9..26b1a1170 100644 --- a/login_server/src/cpp/model/Session.h +++ b/login_server/src/cpp/model/Session.h @@ -19,6 +19,8 @@ #include "../controller/EmailVerificationCode.h" +#include "model/gradido/Transaction.h" + #include "Poco/Thread.h" #include "Poco/Types.h" #include "Poco/DateTime.h" @@ -163,6 +165,8 @@ public: // ------------------------ transactions functions ---------------------------- + inline void setLastTransaction(Poco::AutoPtr lastTransaction) { lock(); mLastTransaction = lastTransaction; unlock(); } + bool lastTransactionTheSame(Poco::AutoPtr newTransaction); inline LanguageCatalog* getLanguageCatalog() { return mLanguageCatalog.isNull() ? nullptr : mLanguageCatalog; } void setLanguage(Languages lang); @@ -188,6 +192,7 @@ protected: private: + int mHandleId; Poco::AutoPtr mNewUser; std::string mPassphrase; @@ -200,6 +205,7 @@ private: Poco::AutoPtr mEmailVerificationCodeObject; std::shared_mutex mSharedMutex; + Poco::AutoPtr mLastTransaction; SessionStates mState; diff --git a/login_server/src/cpp/model/gradido/Transaction.cpp b/login_server/src/cpp/model/gradido/Transaction.cpp index 22ac8937f..16555c485 100644 --- a/login_server/src/cpp/model/gradido/Transaction.cpp +++ b/login_server/src/cpp/model/gradido/Transaction.cpp @@ -630,6 +630,31 @@ namespace model { } + bool Transaction::isTheSameTransaction(Poco::AutoPtr other) + { + bool result = false; + + auto other_proto = other->getTransactionBody()->getBody(); + auto other_created = other_proto->created(); + auto own_body_bytes = getTransactionBody()->getBodyBytes(); + auto own_body_updated = new proto::gradido::TransactionBody; + own_body_updated->ParseFromString(own_body_bytes); + auto own_created = own_body_updated->mutable_created(); + Poco::Int64 timeDiff = other_created.seconds() - own_created->seconds(); + *own_created = other_created; + + result = own_body_updated->SerializeAsString() == other_proto->SerializeAsString(); + + delete own_body_updated; + + // if they are more than 100 seconds between transaction they consider as not the same + if (abs(timeDiff) > 100) { + return false; + } + + return result; + } + /// TASK //////////////////////// SendTransactionTask::SendTransactionTask(Poco::AutoPtr transaction) diff --git a/login_server/src/cpp/model/gradido/Transaction.h b/login_server/src/cpp/model/gradido/Transaction.h index 80f5e7453..a35376040 100644 --- a/login_server/src/cpp/model/gradido/Transaction.h +++ b/login_server/src/cpp/model/gradido/Transaction.h @@ -86,6 +86,8 @@ namespace model { std::string getTransactionAsJson(bool replaceBase64WithHex = false); inline Poco::AutoPtr getPairedTransaction() { return mPairedTransaction; } + bool isTheSameTransaction(Poco::AutoPtr other); + protected: From 5b3e2fdda7caf87cc9098794bb640418bf22ce89 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 11 Jun 2021 16:53:00 +0200 Subject: [PATCH 16/26] try coverage action from me modified --- .github/workflows/test.yml | 18 +++++++++--------- community_server/Dockerfile | 5 +++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f3d6a28c..1d7a382e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -336,15 +336,15 @@ jobs: # COVERAGE CHECK BACKEND COMMUNITY-SERVER #################################### ########################################################################## - name: backend community | Coverage check - run: | - docker run -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test vendor/bin/coverage-check ./webroot/coverage/clover.xml 14 - # uses: webcraftmedia/coverage-check-action@master - # with: - # report_name: Coverage Backend - # type: simplecov - # result_path: ./coverage/clover.xml - # min_coverage: 8 - # token: ${{ github.token }} + #run: | + # docker run -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test vendor/bin/coverage-check ./webroot/coverage/clover.xml 14 + uses: einhornimmond/coverage-check-action@master + with: + report_name: Coverage Backend + type: phpunit + result_path: ./coverage/coverage.info + min_coverage: 10 + token: ${{ github.token }} #test: # runs-on: ubuntu-latest diff --git a/community_server/Dockerfile b/community_server/Dockerfile index 596c4c98d..c553137c6 100644 --- a/community_server/Dockerfile +++ b/community_server/Dockerfile @@ -23,7 +23,8 @@ RUN apt-get update \ ENV XDEBUG_MODE=coverage -RUN composer require --dev rregeer/phpunit-coverage-check +#RUN composer require --dev rregeer/phpunit-coverage-check -CMD ./vendor/bin/phpunit --coverage-clover=./webroot/coverage/clover.xml +#CMD ./vendor/bin/phpunit --coverage-clover=./webroot/coverage/clover.xml +CMD ./vendor/bin/phpunit --coverage-text=./webroot/coverage/coverage.info From 3e71d5423cbede3ed7bb52f6bf0534340886d2fb Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 11 Jun 2021 17:18:26 +0200 Subject: [PATCH 17/26] make coverage report names unique --- .github/workflows/test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1d7a382e3..076453d9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -265,7 +265,7 @@ jobs: - name: backend login | Coverage check uses: webcraftmedia/coverage-check-action@master with: - report_name: Coverage Backend + report_name: Coverage Backend Login type: lcov result_path: ./coverage/coverage.info min_coverage: 13 @@ -336,11 +336,9 @@ jobs: # COVERAGE CHECK BACKEND COMMUNITY-SERVER #################################### ########################################################################## - name: backend community | Coverage check - #run: | - # docker run -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test vendor/bin/coverage-check ./webroot/coverage/clover.xml 14 uses: einhornimmond/coverage-check-action@master with: - report_name: Coverage Backend + report_name: Coverage Backend Community type: phpunit result_path: ./coverage/coverage.info min_coverage: 10 From 8e797776ea0a48a5fbfd8bd8fe254d2de38542ab Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Sun, 13 Jun 2021 19:03:19 +0200 Subject: [PATCH 18/26] remove transaction date in gdd send --- frontend/src/views/Pages/AccountOverview.vue | 3 --- .../AccountOverview/GddSend/TransactionConfirmation.vue | 5 ----- 2 files changed, 8 deletions(-) diff --git a/frontend/src/views/Pages/AccountOverview.vue b/frontend/src/views/Pages/AccountOverview.vue index 561edbf9c..35490e093 100644 --- a/frontend/src/views/Pages/AccountOverview.vue +++ b/frontend/src/views/Pages/AccountOverview.vue @@ -17,7 +17,6 @@ :email="transactionData.email" :amount="transactionData.amount" :memo="transactionData.memo" - :date="transactionData.target_date" :loading="loading" @send-transaction="sendTransaction" @on-reset="onReset" @@ -54,7 +53,6 @@ const EMPTY_TRANSACTION_DATA = { email: '', amount: 0, memo: '', - target_date: '', } export default { @@ -96,7 +94,6 @@ export default { }, methods: { setTransaction(data) { - data.target_date = new Date(Date.now()).toISOString() this.transactionData = data this.currentTransactionStep = 1 }, diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue index b4852df48..d81311b79 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue +++ b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue @@ -16,10 +16,6 @@ {{ memo ? memo : '-' }} {{ $t('form.message') }} - - {{ $d($moment(date), 'long') }} - {{ $t('form.date') }} -
@@ -42,7 +38,6 @@ export default { email: { type: String, default: '' }, amount: { type: Number, default: 0 }, memo: { type: String, default: '' }, - date: { type: String, default: '' }, loading: { type: Boolean, default: false }, }, } From 088b144ee86a82fdcba96158cc9deb698d21579d Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Sun, 13 Jun 2021 19:26:05 +0200 Subject: [PATCH 19/26] simple spec for user profile --- frontend/src/views/Pages/UserProfile.spec.js | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 frontend/src/views/Pages/UserProfile.spec.js diff --git a/frontend/src/views/Pages/UserProfile.spec.js b/frontend/src/views/Pages/UserProfile.spec.js new file mode 100644 index 000000000..7716be9cf --- /dev/null +++ b/frontend/src/views/Pages/UserProfile.spec.js @@ -0,0 +1,23 @@ +import { shallowMount } from '@vue/test-utils' + +import UserProfile from './UserProfile' + +const localVue = global.localVue + +describe('UserProfile', () => { + let wrapper + + const Wrapper = () => { + return shallowMount(UserProfile, { localVue }) + } + + describe('shallowMount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component', () => { + expect(wrapper.findComponent({ name: 'user-card' }).exists()).toBeTruthy() + }) + }) +}) From f127d5408f4e26b1c643e360134fc8e3fcc6c827 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Sun, 13 Jun 2021 19:47:08 +0200 Subject: [PATCH 20/26] no digits after period or comma is allowed. localize numbers in vaidation message --- frontend/src/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/main.js b/frontend/src/main.js index 20c8ffcb8..160ff73c7 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -54,10 +54,14 @@ extend('max', { extend('gddSendAmount', { validate(value, { min, max }) { value = value.replace(',', '.') - return value.match(/^[0-9]+(\.[0-9]{1,2})?$/) && Number(value) >= min && Number(value) <= max + return value.match(/^[0-9]+(\.[0-9]{0,2})?$/) && Number(value) >= min && Number(value) <= max }, params: ['min', 'max'], - message: (_, values) => i18n.t('form.validation.gddSendAmount', values), + message: (_, values) => { + values.min = i18n.n(values.min) + values.max = i18n.n(values.max) + return i18n.t('form.validation.gddSendAmount', values) + }, }) // eslint-disable-next-line camelcase From 617b3648f4006f447347ff22a7e1bab1efac1af7 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 14 Jun 2021 10:54:32 +0200 Subject: [PATCH 21/26] remove check decays for being at least 100 GDD cent - remove debugging lines and empty lines --- .../src/Model/Table/TransactionsTable.php | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index c4bc4b698..5b4099c34 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -178,25 +178,18 @@ class TransactionsTable extends Table } if($prev && $decay == true) { - if($prev->balance > 0) { - // var_dump($stateUserTransactions); $current = $su_transaction; - //echo "decay between " . $prev->transaction_id . " and " . $current->transaction_id . "
"; + $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); - $balance = floatval($prev->balance - $calculated_decay['balance']); - // skip small decays (smaller than 0,00 GDD) + $balance = floatval($prev->balance - $calculated_decay['balance']); - if(abs($balance) >= 100) { - //echo $interval->format('%R%a days'); - //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "
"; - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), - 'memo' => '' - ]; - } + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), + 'memo' => '' + ]; } } @@ -207,9 +200,7 @@ class TransactionsTable extends Table // date // balance $transaction = $transaction_indiced[$su_transaction->transaction_id]; - /*echo "transaction:
"; - var_dump($transaction); - echo "
";*/ + if($su_transaction->transaction_type_id == 1) { // creation $creation = $transaction->transaction_creation; $balance = $stateBalancesTable->calculateDecay($creation->amount, $creation->target_date, $transaction->received); @@ -270,15 +261,14 @@ class TransactionsTable extends Table $duration = $decay_start_date->timeAgoInWords(); } $balance = floatval($su_transaction->balance - $calculated_decay['balance']); - if($balance > 100) { - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $duration, - 'last_decay' => true, - 'memo' => '' - ]; - } + + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $duration, + 'last_decay' => true, + 'memo' => '' + ]; } } From c2d91a20967b4eb99ff037128edb18de11bba81c Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Mon, 14 Jun 2021 11:51:21 +0200 Subject: [PATCH 22/26] add checking at least that decay balance is more than 0 --- .../src/Model/Table/TransactionsTable.php | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 5b4099c34..7e59c2d88 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -184,12 +184,15 @@ class TransactionsTable extends Table $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); $balance = floatval($prev->balance - $calculated_decay['balance']); - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), - 'memo' => '' - ]; + if($balance) + { + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), + 'memo' => '' + ]; + } } } @@ -262,13 +265,16 @@ class TransactionsTable extends Table } $balance = floatval($su_transaction->balance - $calculated_decay['balance']); - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $duration, - 'last_decay' => true, - 'memo' => '' - ]; + if($balance) + { + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $duration, + 'last_decay' => true, + 'memo' => '' + ]; + } } } From a3fd334674abb2c1cf172c2dfcf196f5e15a9b05 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 14 Jun 2021 14:12:29 +0200 Subject: [PATCH 23/26] change 100 to 10 seconds timeout for double transaction --- login_server/src/cpp/model/gradido/Transaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/login_server/src/cpp/model/gradido/Transaction.cpp b/login_server/src/cpp/model/gradido/Transaction.cpp index 16555c485..404d4f747 100644 --- a/login_server/src/cpp/model/gradido/Transaction.cpp +++ b/login_server/src/cpp/model/gradido/Transaction.cpp @@ -647,8 +647,8 @@ namespace model { delete own_body_updated; - // if they are more than 100 seconds between transaction they consider as not the same - if (abs(timeDiff) > 100) { + // if they are more than 10 seconds between transaction they consider as not the same + if (abs(timeDiff) > 10) { return false; } From 40458424359992e70562bf534021bd40408e9c1a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 14 Jun 2021 15:15:01 +0200 Subject: [PATCH 24/26] update user profile data toats messages. Removed TestData fragments. removed unused components --- frontend/src/apis/loginAPI.js | 1 - frontend/src/locales/de.json | 5 ++- frontend/src/locales/en.json | 5 ++- .../src/views/Layout/DashboardLayout_gdd.vue | 6 --- frontend/src/views/Pages/ForgotPassword.vue | 9 ++--- frontend/src/views/Pages/UserProfile.spec.js | 23 ----------- frontend/src/views/Pages/UserProfile.vue | 28 ------------- .../UserProfile/UserCard_FormUserData.vue | 40 ++++++++++--------- .../UserProfile/UserCard_FormUsername.vue | 3 -- .../src/views/Pages/UserProfileOverview.vue | 3 +- 10 files changed, 34 insertions(+), 89 deletions(-) delete mode 100644 frontend/src/views/Pages/UserProfile.spec.js delete mode 100644 frontend/src/views/Pages/UserProfile.vue diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 2eeec754e..3453bd296 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -98,7 +98,6 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) }, - changePassword: async (sessionId, email, password) => { const payload = { session_id: sessionId, diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index f47493aea..f358d3169 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -109,7 +109,10 @@ "chart":"Gemeinschaftsstunden Chart", "new":"Neue Gemeinschaftsstunden eintragen", "list":"Meine Gemeinschaftsstunden Liste" - } + }, + "user-data": { + "change-success": "Deine Daten wurden gespeichert." + } }, "navbar" : { "my-profil":"Mein Profil", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index dbb9b445c..edee8c8c3 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -110,7 +110,10 @@ "chart":"Community Hours Chart", "new":"Register new community hours", "list":"My Community Hours List" - } + }, + "user-data": { + "change-success": "Your data has been saved." + } }, "navbar" : { "my-profil":"My profile", diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index 564b4e430..66814b733 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -34,7 +34,6 @@ :transactions="transactions" :transactionCount="transactionCount" :pending="pending" - :UserProfileTestData="UserProfileTestData" @update-balance="updateBalance" @update-transactions="updateTransactions" > @@ -86,11 +85,6 @@ export default { bookedBalance: 0, transactionCount: 0, pending: true, - UserProfileTestData: { - username: 'Mustermax', - desc: - 'Max Mustermann seine Beschreibung. Max Mustermann seine Beschreibung. Max Mustermann seine Beschreibung. Max Mustermann seine Beschreibung. ', - }, } }, methods: { diff --git a/frontend/src/views/Pages/ForgotPassword.vue b/frontend/src/views/Pages/ForgotPassword.vue index 37077064c..75fc65048 100644 --- a/frontend/src/views/Pages/ForgotPassword.vue +++ b/frontend/src/views/Pages/ForgotPassword.vue @@ -61,12 +61,9 @@ export default { created() {}, methods: { async onSubmit() { - const result = await loginAPI.sendEmail(this.form.email) - if (result.success) { - this.$router.push('/thx/password') - } else { - this.$toast.success(this.$t('error.error')) - } + await loginAPI.sendEmail(this.form.email) + // always give success to avoid email spying + this.$router.push('/thx/password') }, }, } diff --git a/frontend/src/views/Pages/UserProfile.spec.js b/frontend/src/views/Pages/UserProfile.spec.js deleted file mode 100644 index 7716be9cf..000000000 --- a/frontend/src/views/Pages/UserProfile.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -import { shallowMount } from '@vue/test-utils' - -import UserProfile from './UserProfile' - -const localVue = global.localVue - -describe('UserProfile', () => { - let wrapper - - const Wrapper = () => { - return shallowMount(UserProfile, { localVue }) - } - - describe('shallowMount', () => { - beforeEach(() => { - wrapper = Wrapper() - }) - - it('renders the component', () => { - expect(wrapper.findComponent({ name: 'user-card' }).exists()).toBeTruthy() - }) - }) -}) diff --git a/frontend/src/views/Pages/UserProfile.vue b/frontend/src/views/Pages/UserProfile.vue deleted file mode 100644 index 882b52e78..000000000 --- a/frontend/src/views/Pages/UserProfile.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index e07313c96..1fa26b5e0 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -9,8 +9,8 @@ @@ -19,7 +19,7 @@ {{ $t('form.firstname') }} - - {{ $store.state.firstName }} + + {{ form.firstName }} @@ -45,8 +45,8 @@ {{ $t('form.lastname') }} - - {{ $store.state.lastName }} + + {{ form.lastName }} @@ -56,15 +56,15 @@ {{ $t('form.description') }} - - {{ $store.state.description }} + + {{ form.description }} - +
- + @@ -22,7 +22,6 @@ export default { props: { balance: { type: Number, default: 0 }, transactionCount: { type: Number, default: 0 }, - UserProfileTestData: { type: Object }, }, } From 9f5edda4662940ad37ecbb2fb056887403cb94ea Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 14 Jun 2021 15:24:09 +0200 Subject: [PATCH 25/26] toast errors on password reset --- frontend/src/views/Pages/ResetPassword.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index de8f8cad8..2647e8fa0 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -115,9 +115,7 @@ export default { */ this.$router.push('/thx/reset') } else { - this.$bvToast.toast(result.result.message, { - title: this.$t('error.error'), - }) + this.$toast.error(result.result.message) } }, async authenticate() { @@ -128,9 +126,7 @@ export default { this.sessionId = result.result.data.session_id this.email = result.result.data.user.email } else { - this.$bvToast.toast(result.result.message, { - title: this.$t('error.error'), - }) + this.$toast.error(result.result.message) } }, }, From be242518aed49916067350bc66799cd7163540ae Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 14 Jun 2021 15:46:13 +0200 Subject: [PATCH 26/26] test user profile overview --- .../views/Pages/UserProfileOverview.spec.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 frontend/src/views/Pages/UserProfileOverview.spec.js diff --git a/frontend/src/views/Pages/UserProfileOverview.spec.js b/frontend/src/views/Pages/UserProfileOverview.spec.js new file mode 100644 index 000000000..617e0ade0 --- /dev/null +++ b/frontend/src/views/Pages/UserProfileOverview.spec.js @@ -0,0 +1,38 @@ +import { shallowMount } from '@vue/test-utils' +import UserProfileOverview from './UserProfileOverview' + +const localVue = global.localVue + +describe('UserProfileOverview', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + } + + const Wrapper = () => { + return shallowMount(UserProfileOverview, { localVue, mocks }) + } + + describe('shallow Mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has a user card', () => { + expect(wrapper.findComponent({ name: 'UserCard' }).exists()).toBeTruthy() + }) + + it('has a user data form', () => { + expect(wrapper.findComponent({ name: 'FormUserData' }).exists()).toBeTruthy() + }) + + it('has a user name form', () => { + expect(wrapper.findComponent({ name: 'FormUsername' }).exists()).toBeTruthy() + }) + + it('has a user password form', () => { + expect(wrapper.findComponent({ name: 'FormUserPasswort' }).exists()).toBeTruthy() + }) + }) +})