Merge branch 'master' into static_decay_block

This commit is contained in:
Alexander Friedland 2022-02-04 09:14:50 +01:00 committed by Ulf Gebhardt
commit 912e35090a
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
680 changed files with 2373 additions and 99912 deletions

View File

@ -106,43 +106,6 @@ jobs:
name: docker-database-production_up
path: /tmp/database_up.tar
##############################################################################
# JOB: DOCKER BUILD PRODUCTION COMMUNITY SERVER ##############################
##############################################################################
build_production_community_server:
name: Docker Build Production - Community Server
runs-on: ubuntu-latest
#needs: [nothing]
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v2
##########################################################################
# SET ENVS ###############################################################
##########################################################################
- name: ENV - VERSION
run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
- name: ENV - BUILD_DATE
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: ENV - BUILD_VERSION
run: echo "BUILD_VERSION=${VERSION}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: ENV - BUILD_COMMIT
run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
##########################################################################
# COMMUNITY SERVER #######################################################
##########################################################################
- name: Community Server | Build `production` image
run: |
docker build -t "gradido/community_server:latest" -t "gradido/community_server:production" -t "gradido/community_server:${VERSION}" -t "gradido/community_server:${BUILD_VERSION}" -f ./community_server/Dockerfile ./
docker save "gradido/community_server" > /tmp/community_server.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: docker-community-server-production
path: /tmp/community_server.tar
##############################################################################
# JOB: DOCKER BUILD PRODUCTION MARIADB #######################################
##############################################################################
@ -223,7 +186,7 @@ jobs:
upload_to_dockerhub:
name: Upload to Dockerhub
runs-on: ubuntu-latest
needs: [build_production_frontend, build_production_backend, build_production_database_up, build_production_community_server, build_production_mariadb, build_production_nginx]
needs: [build_production_frontend, build_production_backend, build_production_database_up, build_production_mariadb, build_production_nginx]
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
@ -257,13 +220,6 @@ jobs:
path: /tmp
- name: Load Docker Image
run: docker load < /tmp/database_up.tar
- name: Download Docker Image (Community Server)
uses: actions/download-artifact@v2
with:
name: docker-community-server-production
path: /tmp
- name: Load Docker Image
run: docker load < /tmp/community_server.tar
- name: Download Docker Image (MariaDB)
uses: actions/download-artifact@v2
with:
@ -289,8 +245,6 @@ jobs:
run: docker push --all-tags gradido/backend
- name: Push database
run: docker push --all-tags gradido/database
- name: Push community_server
run: docker push --all-tags gradido/community_server
- name: Push MariaDB
run: docker push --all-tags gradido/mariadb
- name: Push Nginx
@ -351,7 +305,7 @@ jobs:
- name: yarn install
run: yarn install
- name: generate changelog
run: yarn auto-changelog --latest-version ${{ env.VERSION }} --unreleased-only
run: yarn auto-changelog --commit-limit 0 --latest-version ${{ env.VERSION }} --unreleased-only
- name: package-version-to-git-release
continue-on-error: true # Will fail if tag exists
id: create_release

View File

@ -107,32 +107,6 @@ jobs:
name: docker-database-test_up
path: /tmp/database_up.tar
##############################################################################
# JOB: DOCKER BUILD TEST COMMUNITY SERVER ####################################
##############################################################################
build_test_community_server:
name: Docker Build Test - Community Server
runs-on: ubuntu-latest
#needs: [nothing]
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v2
##########################################################################
# BUILD COMMUNITY SERVER DOCKER IMAGE ####################################
##########################################################################
- name: community server | Build `test` image
run: |
docker build -t "gradido/community_server:test" -f ./community_server/Dockerfile ./
docker save "gradido/community_server:test" > /tmp/community_server.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: docker-community-server-test
path: /tmp/community_server.tar
##############################################################################
# JOB: DOCKER BUILD TEST MARIADB #############################################
##############################################################################
@ -448,7 +422,7 @@ jobs:
report_name: Coverage Admin Interface
type: lcov
result_path: ./coverage/lcov.info
min_coverage: 81
min_coverage: 94
token: ${{ github.token }}
##############################################################################
@ -509,73 +483,6 @@ jobs:
min_coverage: 38
token: ${{ github.token }}
##############################################################################
# JOB: UNIT TEST COMMUNITY-SERVER ###########################################
##############################################################################
unit_test_community_server:
name: Unit tests - Community Server
runs-on: ubuntu-latest
needs: [build_test_community_server]
services:
mariadb:
image: gradido/mariadb:test
env:
MARIADB_ALLOW_EMPTY_PASSWORD: 1
MARIADB_USER: root
options: --health-cmd="mysqladmin ping"
--health-interval=5s
--health-timeout=5s
--health-retries=3
steps:
- name: get mariadb container id
run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')"
id: mariadb_container
- name: get automatic created network
run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')"
id: network
- name: Start database migration
run: docker run --network ${{ steps.network.outputs.id }} --name=database --env NODE_ENV=production --env DB_HOST=mariadb --env DB_DATABASE=gradido_community_test -d gradido/database:production_up
- name: get database migration container id
run: echo "::set-output name=id::$(docker container ls | grep database | awk '{ print $1 }')"
id: database_container
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v2
##########################################################################
# DOWNLOAD DOCKER IMAGE ##################################################
##########################################################################
- name: Download Docker Image (Community-Server)
uses: actions/download-artifact@v2
with:
name: docker-community-server-test
path: /tmp
- name: Load Docker Image
run: docker load < /tmp/community_server.tar
- name: check mariadb
run: docker logs ${{ steps.mariadb_container.outputs.id }}
- name: check migration
run: docker logs ${{ steps.database_container.outputs.id }}
##########################################################################
# UNIT TESTS BACKEND COMMUNITY-SERVER #######################################
##########################################################################
- name: community server | Unit tests
run: |
docker run --network ${{ steps.network.outputs.id }} -v ~/coverage:/var/www/cakephp/webroot/coverage gradido/community_server:test
cp -r ~/coverage ./coverage
#########################################################################
# COVERAGE CHECK BACKEND COMMUNITY-SERVER ####################################
##########################################################################
- name: backend community | Coverage check
uses: einhornimmond/coverage-check-action@master
with:
report_name: Coverage Backend Community
type: phpunit
result_path: ./coverage/coverage.info
min_coverage: 10
token: ${{ github.token }}
##########################################################################
# DATABASE MIGRATION TEST UP + RESET #####################################
##########################################################################

7
.gitmodules vendored
View File

@ -1,8 +1 @@
[submodule "gn"]
path = gn
url = https://github.com/gradido/gn.git
branch = master
[submodule "community_server/src/protobuf"]
path = community_server/src/protobuf
url = https://github.com/gradido/gradido_protocol.git

View File

@ -4,13 +4,80 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [1.6.5](https://github.com/gradido/gradido/compare/1.6.4...1.6.5)
> 15 February 2022
- v1.6.5 [`#1497`](https://github.com/gradido/gradido/pull/1497)
- Fix: Elopage Hook Crash 2 [`#1481`](https://github.com/gradido/gradido/pull/1481)
#### [1.6.4](https://github.com/gradido/gradido/compare/1.6.3...1.6.4)
> 14 February 2022
- v1.6.4 [`#1478`](https://github.com/gradido/gradido/pull/1478)
- fix: Admin Email Confirmation Date and Time [`#1448`](https://github.com/gradido/gradido/pull/1448)
- Fix: Do not log password or token to the console [`#1477`](https://github.com/gradido/gradido/pull/1477)
- Fix: Elopage Hook Crash [`#1474`](https://github.com/gradido/gradido/pull/1474)
- 538 unify all buttons [`#1455`](https://github.com/gradido/gradido/pull/1455)
- 833 old error is shown for a second even if transaction is successful [`#1460`](https://github.com/gradido/gradido/pull/1460)
- fix: Wrong Email Spelling in German [`#1446`](https://github.com/gradido/gradido/pull/1446)
- fix: Redirect to Login after Register [`#1445`](https://github.com/gradido/gradido/pull/1445)
- refactor: Split User Table Component in Admin Interface [`#1443`](https://github.com/gradido/gradido/pull/1443)
#### [1.6.3](https://github.com/gradido/gradido/compare/1.6.2...1.6.3)
> 9 February 2022
- v1.6.3 [`#1447`](https://github.com/gradido/gradido/pull/1447)
- add .btn-outline-secondary in scss [`#1442`](https://github.com/gradido/gradido/pull/1442)
- Profil settings and footer refactor [`#1440`](https://github.com/gradido/gradido/pull/1440)
#### [1.6.2](https://github.com/gradido/gradido/compare/1.6.1...1.6.2)
> 8 February 2022
- v1.6.2 [`#1438`](https://github.com/gradido/gradido/pull/1438)
- updated_changelog_library [`#1437`](https://github.com/gradido/gradido/pull/1437)
- admin interface does user have member area [`#1416`](https://github.com/gradido/gradido/pull/1416)
- Refactor - Remove community_server [`#1408`](https://github.com/gradido/gradido/pull/1408)
- 1389 transactions tabs are not well designed [`#1425`](https://github.com/gradido/gradido/pull/1425)
- fix_community_name_description [`#1429`](https://github.com/gradido/gradido/pull/1429)
- remove_unnecessary_repositories [`#1406`](https://github.com/gradido/gradido/pull/1406)
- clean_database_users [`#1427`](https://github.com/gradido/gradido/pull/1427)
- remove_gradido_node [`#1431`](https://github.com/gradido/gradido/pull/1431)
- add updateTransactions function for GDD balance if reload page [`#1423`](https://github.com/gradido/gradido/pull/1423)
- 1390 display error when navigating to send form without any gdd [`#1424`](https://github.com/gradido/gradido/pull/1424)
- have an delete button for the search input [`#1413`](https://github.com/gradido/gradido/pull/1413)
- reset all selected users in mass creation [`#1422`](https://github.com/gradido/gradido/pull/1422)
- combine_user_tables [`#1411`](https://github.com/gradido/gradido/pull/1411)
- feat: Test Table Row Details Toggling [`#1420`](https://github.com/gradido/gradido/pull/1420)
- feat: Improved Tests for Mass Creation [`#1419`](https://github.com/gradido/gradido/pull/1419)
- refactor: Mixin for Creation Labels [`#1409`](https://github.com/gradido/gradido/pull/1409)
- Marque community_server as to be removed. [`#1407`](https://github.com/gradido/gradido/pull/1407)
- database_transaction_signatures [`#1368`](https://github.com/gradido/gradido/pull/1368)
- database_pending_creations [`#1367`](https://github.com/gradido/gradido/pull/1367)
- fix_seed [`#1410`](https://github.com/gradido/gradido/pull/1410)
- clean_database [`#1362`](https://github.com/gradido/gradido/pull/1362)
- multiple creation already selected users remain saved [`#1376`](https://github.com/gradido/gradido/pull/1376)
- fix: Localize Datetime in Admin Interface [`#1327`](https://github.com/gradido/gradido/pull/1327)
- feat: Remove Login Server [`#1383`](https://github.com/gradido/gradido/pull/1383)
- refactor: Tag Last Version with Login Server [`#1391`](https://github.com/gradido/gradido/pull/1391)
- if an email is not confirmed, a user cannot be added to any multiple … [`#1374`](https://github.com/gradido/gradido/pull/1374)
- cleanups_refactors [`#1404`](https://github.com/gradido/gradido/pull/1404)
- 1365 clear bootstrap version for vue2, preparation for new template [`#1366`](https://github.com/gradido/gradido/pull/1366)
- upgrade vue version from ^2.6.11 to 2.6.12 [`#1382`](https://github.com/gradido/gradido/pull/1382)
- remove vue-qrcode from dashboard-plugin [`#1364`](https://github.com/gradido/gradido/pull/1364)
- remove unused package from frontend [`#1360`](https://github.com/gradido/gradido/pull/1360)
#### [1.6.1](https://github.com/gradido/gradido/compare/1.6.0...1.6.1)
> 28 January 2022
- Hotfix elopage [`#1358`](https://github.com/gradido/gradido/pull/1358)
- change standard text für creation [`#1343`](https://github.com/gradido/gradido/pull/1343)
- Check if user email is activated to make a creation. [`#1356`](https://github.com/gradido/gradido/pull/1356)
- fix: Creation Confirmation User Ids [`#1345`](https://github.com/gradido/gradido/pull/1345)
- fix and improve test [`1c833d3`](https://github.com/gradido/gradido/commit/1c833d394f502a7aed2b5a648c0171a2fe4ee1e6)
- rewrote elopage hook to handle actual elopage hook [`65bc347`](https://github.com/gradido/gradido/commit/65bc3479fa169920eff57b5a2fa662a4090d7364)
- simple test for mass creation, improved test for single creation [`ffc4727`](https://github.com/gradido/gradido/commit/ffc4727e7a7105ac5dc97515b901be8dbe415627)
#### [1.6.0](https://github.com/gradido/gradido/compare/1.5.1...1.6.0)
@ -169,16 +236,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- analyse_bundle [`#1019`](https://github.com/gradido/gradido/pull/1019)
- release_issue_template [`#1013`](https://github.com/gradido/gradido/pull/1013)
- fix_changelog [`#1014`](https://github.com/gradido/gradido/pull/1014)
- removed incorrect mnemonic lists [`08200f4`](https://github.com/gradido/gradido/commit/08200f49f2ceb5ac121534a19ad2a8347c900145)
- update jest, install transform-require-context [`165ed18`](https://github.com/gradido/gradido/commit/165ed1801ba1aba862d0b0006d8c17e322c4b7ff)
- rework roadmap [`b337bcd`](https://github.com/gradido/gradido/commit/b337bcd850423e67b2119c562575b0ec692dddf2)
#### [1.5.1](https://github.com/gradido/gradido/compare/1.5.0...1.5.1)
> 15 October 2021
- fix isExitInDb [`#994`](https://github.com/gradido/gradido/pull/994)
- fix [`80228ef`](https://github.com/gradido/gradido/commit/80228ef842d4087ea4b80934b15b8112611e3e33)
#### [1.5.0](https://github.com/gradido/gradido/compare/1.4.0...1.5.0)
@ -255,9 +318,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- update docker files [`#830`](https://github.com/gradido/gradido/pull/830)
- added publisher_id field to user [`#245`](https://github.com/gradido/gradido/pull/245)
- webpack update [`#811`](https://github.com/gradido/gradido/pull/811)
- resolvers [`562ad9a`](https://github.com/gradido/gradido/commit/562ad9ae31d97f90a371452bed1ffe10ebf2d3a5)
- deleted inputs (now args) [`8ab542a`](https://github.com/gradido/gradido/commit/8ab542a28acf6b78d7a9e7fe7757363d225f7b4f)
- fix UserCard_CoinAnimation to properly use the store, have 100% coverage and other minor fixes & simplifications [`ce826de`](https://github.com/gradido/gradido/commit/ce826deb1d6d92caba514713539dca2da3f74de7)
#### [1.4.0](https://github.com/gradido/gradido/compare/1.3.1...1.4.0)
@ -299,9 +359,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- feat: Vue Apollo Client [`#701`](https://github.com/gradido/gradido/pull/701)
- change text from Geld to Gradidos [`#711`](https://github.com/gradido/gradido/pull/711)
- fix fix [`#728`](https://github.com/gradido/gradido/pull/728)
- sort locales [`ec12a28`](https://github.com/gradido/gradido/commit/ec12a28f81577d530f58b42b7f8c2c7d20dffd64)
- feat: Unify and Sort Locales [`aba4f4d`](https://github.com/gradido/gradido/commit/aba4f4d20e0a13016e3528a1c5c30c111eb3a9f1)
- feat: Increase Coverage [`3c061bc`](https://github.com/gradido/gradido/commit/3c061bcb8d1a3a47442ed6a351e1428e15b314aa)
#### [1.3.1](https://github.com/gradido/gradido/compare/1.3.0...1.3.1)
@ -310,9 +367,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix: Translations and Formula Display [`#727`](https://github.com/gradido/gradido/pull/727)
- 612 docu structure [`#688`](https://github.com/gradido/gradido/pull/688)
- Community update for gdt list GDT transaction format [`#726`](https://github.com/gradido/gradido/pull/726)
- [#612] new directory structure in /docu/Concepts [`10bf3b0`](https://github.com/gradido/gradido/commit/10bf3b0cdfa6c44f879be0155e93f636601a051b)
- #612 additional documents [`ac0ed4f`](https://github.com/gradido/gradido/commit/ac0ed4fee81caff26d09b5de47dd130f12abdb45)
- #612 docu restructuring [`e67e1c4`](https://github.com/gradido/gradido/commit/e67e1c41e78264698e6fae4cf1d29751de7e7b29)
#### [1.3.0](https://github.com/gradido/gradido/compare/1.2.1...1.3.0)
@ -334,9 +388,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Backend Setup [`#584`](https://github.com/gradido/gradido/pull/584)
- text-size in textarea and font-variante if focus [`#677`](https://github.com/gradido/gradido/pull/677)
- 680 app large maximum width [`#681`](https://github.com/gradido/gradido/pull/681)
- linting, server is working [`34b30b2`](https://github.com/gradido/gradido/commit/34b30b216b6fafcb5b686d4b023b05f2e9766bdf)
- server stack seems to work. Graphql does not load properly yet [`43f7cf8`](https://github.com/gradido/gradido/commit/43f7cf87679713d436a64d569d6af1594a12ee33)
- initial commit, base packages [`fdf0979`](https://github.com/gradido/gradido/commit/fdf0979830fece04208a6b3bb06bb5323a3c149b)
#### [1.2.1](https://github.com/gradido/gradido/compare/1.2.0...1.2.1)
@ -347,9 +398,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix unneccessary migration run on fresh (docker) setup [`#654`](https://github.com/gradido/gradido/pull/654)
- move back decay as standalone transaction in old frontend [`#656`](https://github.com/gradido/gradido/pull/656)
- fix display error with creation [`#652`](https://github.com/gradido/gradido/pull/652)
- release [`a0b8056`](https://github.com/gradido/gradido/commit/a0b8056c17b22570a1b1dbb6fa6ce71e561b04af)
- update content for frontend [`d37ce09`](https://github.com/gradido/gradido/commit/d37ce0949ef97d2a6c6ffaf0be31db9f6d92e743)
- exchange positions [`bc000ef`](https://github.com/gradido/gradido/commit/bc000efd87c9701480c4aeaa7b819ab49bfe8f01)
#### [1.2.0](https://github.com/gradido/gradido/compare/1.1.1...1.2.0)
@ -388,9 +436,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Update Password Reset E-Mail Subject Encoding [`#579`](https://github.com/gradido/gradido/pull/579)
- move decay between transactions into the transactions [`#483`](https://github.com/gradido/gradido/pull/483)
- fix #591 [`#591`](https://github.com/gradido/gradido/issues/591)
- fix style decay startblick [`cc7778b`](https://github.com/gradido/gradido/commit/cc7778b55d1baaa7be2d9440480e0fb27bb9a930)
- Remove dynamic cast because it lead to errors again and agin (Poco::AutoPtr don't work correct with that) [`0db5912`](https://github.com/gradido/gradido/commit/0db5912a67158be8f313c01f06350f8339cb0e28)
- Remove dynamic cast because it lead to errors again and agin (Poco::AutoPtr don't work correct with that) [`cee7d7a`](https://github.com/gradido/gradido/commit/cee7d7ac3c4c8c1f481cc3a87fb15422c858413b)
#### [1.1.1](https://github.com/gradido/gradido/compare/1.1.0...1.1.1)
@ -401,9 +446,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- update transfer email text [`#574`](https://github.com/gradido/gradido/pull/574)
- update mysql because tuple has changed [`#576`](https://github.com/gradido/gradido/pull/576)
- Login fix pending transactions [`#578`](https://github.com/gradido/gradido/pull/578)
- add test to prevent bug in future [`630d667`](https://github.com/gradido/gradido/commit/630d667e996870a1bf9aa9586b0467d58419e525)
- use standard path. add nginx example [`ac249b4`](https://github.com/gradido/gradido/commit/ac249b46830a8039aec52d30b48084b50a264b6f)
- add autodeploy bash scripts [`f49cf4d`](https://github.com/gradido/gradido/commit/f49cf4d7f8054d87efa1e12055a7ef0c6d3b9872)
#### [1.1.0](https://github.com/gradido/gradido/compare/1.0.2...1.1.0)
@ -445,9 +487,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- login without hedera [`#478`](https://github.com/gradido/gradido/pull/478)
- fix: Show Correct Version Number in Footer [`#475`](https://github.com/gradido/gradido/pull/475)
- refactor: Remove Element-UI [`#476`](https://github.com/gradido/gradido/pull/476)
- remove components Charts, Notification, SearchUser, ButtonCheckbox, Button RadioGroup, Breadcrumb [`159bff7`](https://github.com/gradido/gradido/commit/159bff71df20a5c48f93389b2f990f7fe54e53b9)
- fix bug, update dockerfiles to use dependencies without grpc [`dedcebd`](https://github.com/gradido/gradido/commit/dedcebdb95ee0f3dfd2ad62074d4181af38476a2)
- add warning to able to forward warnings from community server to client [`2fc3fe9`](https://github.com/gradido/gradido/commit/2fc3fe94a09bae199bf2f34f9df90e8fc3879c2b)
#### [1.0.2](https://github.com/gradido/gradido/compare/1.0.1...1.0.2)
@ -474,17 +513,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- add dynamic error email if transaction failed [`#452`](https://github.com/gradido/gradido/pull/452)
- ceil the last decay [`#449`](https://github.com/gradido/gradido/pull/449)
- feat: Raise Coverage of Frontend Unit Tets to 18% [`#447`](https://github.com/gradido/gradido/pull/447)
- parse cpsp files automatic in build [`a4a12bb`](https://github.com/gradido/gradido/commit/a4a12bb62b4000e035ff15e17c5a5f5861653ff6)
- translate german html encoded error messages to english and use gettext for automatic translation [`d339627`](https://github.com/gradido/gradido/commit/d33962736d94c1cb7a12ff775bc2c8d7505d646e)
- 100% coverage of GddTransactionList [`96fb245`](https://github.com/gradido/gradido/commit/96fb245821c69f4d321204a663247d5eee60d92f)
#### [1.0.1](https://github.com/gradido/gradido/compare/1.0.0...1.0.1)
> 14 May 2021
- Login crash fix [`#444`](https://github.com/gradido/gradido/pull/444)
- add try catch blocks to prevent login-server from crashing [`22ff220`](https://github.com/gradido/gradido/commit/22ff22072956f8b843037c75c5b16b7ff5d6a2a3)
- fix [`14a4243`](https://github.com/gradido/gradido/commit/14a424347817b1fe6912a113bffd70e55d688112)
### [1.0.0](https://github.com/gradido/gradido/compare/0.9.4...1.0.0)
@ -604,9 +638,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Background color change [`#117`](https://github.com/gradido/gradido/pull/117)
- Delete unused files [`#116`](https://github.com/gradido/gradido/pull/116)
- store aufräumen teil 1 [`#115`](https://github.com/gradido/gradido/pull/115)
- add migrations table for automatic table data migration [`40a9a8c`](https://github.com/gradido/gradido/commit/40a9a8c2b587f5bef0fcc54136ed7bd13dd91b2b)
- update yarn.lock after running yarn install [`7f38c80`](https://github.com/gradido/gradido/commit/7f38c801213ad886e9d34a8d43b00ae423f5f2a0)
- use new function for balance overview in old frontend, update balance in session on every php-request [`97c570c`](https://github.com/gradido/gradido/commit/97c570c08cc51ed17a69eb8be8d987f95f3c2ce0)
#### [0.9.4](https://github.com/gradido/gradido/compare/0.9.3...0.9.4)
@ -614,9 +645,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Vue with nginx [`#84`](https://github.com/gradido/gradido/pull/84)
- Build on run [`#103`](https://github.com/gradido/gradido/pull/103)
- update debug docker to use dependencies container pushed to docker hub [`1f002f4`](https://github.com/gradido/gradido/commit/1f002f4ed0b12d4b2bf63efceabe546d0c5b58ea)
- removed email tasks complete [`8a143be`](https://github.com/gradido/gradido/commit/8a143be8423d7bd894d4f512848895df8b9694b0)
- build login-server on docker-compose up in a docker volume so it rebuild only neccessary parts if some c++ files have changed [`0da5279`](https://github.com/gradido/gradido/commit/0da527917523530186e6effe63dc001fc99bd3e3)
#### [0.9.3](https://github.com/gradido/gradido/compare/0.9.2...0.9.3)
@ -645,9 +673,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Add Feature in user search old frontend because Support has requested the feature long ago [`#56`](https://github.com/gradido/gradido/pull/56)
- sprache angepasst, for login, pwd, sigin [`#54`](https://github.com/gradido/gradido/pull/54)
- Improve workflows [`#53`](https://github.com/gradido/gradido/pull/53)
- setup eslint with tougher rules [`1f13507`](https://github.com/gradido/gradido/commit/1f13507eacfd93c2248fb841de5f481c9eb1e6bd)
- semicolon rule implemented [`6762a02`](https://github.com/gradido/gradido/commit/6762a028f2a3e4f2713b26bed81029defe686ad7)
- dev meeting, bernd [`a99de7f`](https://github.com/gradido/gradido/commit/a99de7f5d1f7557c0877eae565aa4263d65aaaf3)
#### [0.9.2](https://github.com/gradido/gradido/compare/0.9.1...0.9.2)
@ -657,9 +682,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Reload after login fixed [`#50`](https://github.com/gradido/gradido/pull/50)
- Monorepo login server [`#48`](https://github.com/gradido/gradido/pull/48)
- Stage0 [`#3`](https://github.com/gradido/gradido/pull/3)
- Add auto-sign Transaction functionality [`5592275`](https://github.com/gradido/gradido/commit/55922753a7ffd9552be132501d744da491c409b5)
- read in login the real client ip X-Real-IP from nginx forwarded not from community server [`512d307`](https://github.com/gradido/gradido/commit/512d307a19b955bb6e26ae8b274def354829b50f)
- move check if all passwords allow direct into pwdValidation so it will work with every code which ask for password [`e2c38c1`](https://github.com/gradido/gradido/commit/e2c38c1a0fc25a4a2bc922c4bbc44d86b6d00d8b)
#### 0.9.1
@ -671,6 +693,3 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- [WIP] 2 create a dockerfile for the frontend application [`#6`](https://github.com/gradido/gradido/pull/6)
- Master - first step [`#1`](https://github.com/gradido/gradido/pull/1)
- Add docker compose [`#7`](https://github.com/gradido/gradido/pull/7)
- style 404 side :) [`c7bdf89`](https://github.com/gradido/gradido/commit/c7bdf8978594b932615e48f9bb1c19d3c3bf3fcf)
- publish workflow test [`df6f66f`](https://github.com/gradido/gradido/commit/df6f66ffe70baa9ed3f70b460a6c0c14011bb944)
- many translations. translation structure [`bf68547`](https://github.com/gradido/gradido/commit/bf685479767d19c246c4d6abe3577dc3cb666346)

View File

@ -60,7 +60,6 @@ docker-compose -f docker-compose.yml up
- [frontend](./frontend) Wallet frontend
- [backend](./backend) GraphQL & Business logic backend
- [mariadb](./mariadb) Database backend
- [community_server](./community_server/) Business logic backend
We are currently restructuring the service to reduce dependencies and unify business logic into one place. Furthermore the databases defined for each service will be unified into one.

3
admin/.gitignore vendored
View File

@ -2,7 +2,8 @@ node_modules/
dist/
.cache/
.env
/.env
/.env.bak
# coverage folder
coverage/

View File

@ -3,7 +3,7 @@
"description": "Administraion Interface for Gradido",
"main": "index.js",
"author": "Moriz Wahl",
"version": "1.6.1",
"version": "1.6.5",
"license": "MIT",
"private": false,
"scripts": {

View File

@ -13,3 +13,11 @@ export default {
components: { defaultLayout },
}
</script>
<style>
.pointer {
cursor: pointer;
}
.pointer:hover {
background-color: rgb(216, 213, 213);
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<div class="component-confirm-register-mail">
<div class="shadow p-3 mb-5 bg-white rounded">
<div v-if="checked">{{ $t('unregister_mail.text_true', { date: dateLastSend }) }}</div>
<div v-if="checked">{{ $t('unregister_mail.text_true') }}</div>
<div v-else>
{{ $t('unregister_mail.text_false', { date: dateLastSend, mail: email }) }}

View File

@ -0,0 +1,86 @@
<template>
<div class="component-open-creations-table">
<b-table-lite :items="items" :fields="fields" caption-top striped hover stacked="md">
<template #cell(bookmark)="row">
<b-button
variant="danger"
size="md"
@click="$emit('remove-creation', row.item)"
class="mr-2"
>
<b-icon icon="x" variant="light"></b-icon>
</b-button>
</template>
<template #cell(edit_creation)="row">
<b-button variant="info" size="md" @click="rowToogleDetails(row, 0)" class="mr-2">
<b-icon :icon="row.detailsShowing ? 'x' : 'pencil-square'" aria-label="Help"></b-icon>
</b-button>
</template>
<template #cell(confirm)="row">
<b-button variant="success" size="md" @click="$emit('show-overlay', row.item)" class="mr-2">
<b-icon icon="check" scale="2" variant=""></b-icon>
</b-button>
</template>
<template #row-details="row">
<row-details
:row="row"
type="show-creation"
slotName="show-creation"
:index="0"
@row-toogle-details="rowToogleDetails"
>
<template #show-creation>
<div>
<edit-creation-formular
type="singleCreation"
:creation="row.item.creation"
:item="row.item"
:row="row"
:creationUserData="creationUserData"
@update-creation-data="updateCreationData"
@update-user-data="updateUserData"
/>
</div>
</template>
</row-details>
</template>
</b-table-lite>
</div>
</template>
<script>
import { toggleRowDetails } from '../../mixins/toggleRowDetails'
import RowDetails from '../RowDetails.vue'
import EditCreationFormular from '../EditCreationFormular.vue'
export default {
name: 'OpenCreationsTable',
mixins: [toggleRowDetails],
components: {
EditCreationFormular,
RowDetails,
},
props: {
items: {
type: Array,
required: true,
},
fields: {
type: Array,
required: true,
},
},
methods: {
updateCreationData(data) {
this.creationUserData.amount = data.amount
this.creationUserData.date = data.date
this.creationUserData.memo = data.memo
this.creationUserData.moderator = data.moderator
data.row.toggleDetails()
},
updateUserData(rowItem, newCreation) {
rowItem.creation = newCreation
},
},
}
</script>

View File

@ -0,0 +1,125 @@
<template>
<div class="search-user-table">
<b-table-lite :items="items" :fields="fields" caption-top striped hover stacked="md">
<template #cell(creation)="data">
<div v-html="data.value"></div>
</template>
<template #cell(show_details)="row">
<b-button
variant="info"
size="md"
v-if="row.item.emailChecked"
@click="rowToogleDetails(row, 0)"
class="mr-2"
>
<b-icon :icon="row.detailsShowing ? 'eye-slash-fill' : 'eye-fill'"></b-icon>
</b-button>
</template>
<template #cell(confirm_mail)="row">
<b-button
:variant="row.item.emailChecked ? 'success' : 'danger'"
size="md"
@click="rowToogleDetails(row, 1)"
class="mr-2"
>
<b-icon
:icon="row.item.emailChecked ? 'envelope-open' : 'envelope'"
aria-label="Help"
></b-icon>
</b-button>
</template>
<template #cell(has_elopage)="row">
<b-icon
:variant="row.item.hasElopage ? 'success' : 'danger'"
:icon="row.item.hasElopage ? 'check-circle' : 'x-circle'"
></b-icon>
</template>
<template #cell(transactions_list)="row">
<b-button variant="warning" size="md" @click="rowToogleDetails(row, 2)" class="mr-2">
<b-icon icon="list"></b-icon>
</b-button>
</template>
<template #row-details="row">
<row-details
:row="row"
type="singleCreation"
:slotName="slotName"
:index="slotIndex"
@row-toogle-details="rowToogleDetails"
>
<template #show-creation>
<div>
<creation-formular
type="singleCreation"
pagetype="singleCreation"
:creation="row.item.creation"
:item="row.item"
:creationUserData="creationUserData"
@update-user-data="updateUserData"
/>
</div>
</template>
<template #show-register-mail>
<confirm-register-mail-formular
:checked="row.item.emailChecked"
:email="row.item.email"
:dateLastSend="
row.item.emailConfirmationSend
? $d(new Date(row.item.emailConfirmationSend), 'long')
: ''
"
/>
</template>
<template #show-transaction-list>
<creation-transaction-list-formular :userId="row.item.userId" />
</template>
</row-details>
</template>
</b-table-lite>
</div>
</template>
<script>
import CreationFormular from '../CreationFormular.vue'
import ConfirmRegisterMailFormular from '../ConfirmRegisterMailFormular.vue'
import RowDetails from '../RowDetails.vue'
import CreationTransactionListFormular from '../CreationTransactionListFormular.vue'
import { toggleRowDetails } from '../../mixins/toggleRowDetails'
const slotNames = ['show-creation', 'show-register-mail', 'show-transaction-list']
export default {
name: 'SearchUserTable',
mixins: [toggleRowDetails],
components: {
CreationFormular,
ConfirmRegisterMailFormular,
CreationTransactionListFormular,
RowDetails,
},
props: {
items: {
type: Array,
required: true,
},
fields: {
type: Array,
required: true,
},
},
data() {
return {
creationUserData: {},
}
},
methods: {
updateUserData(rowItem, newCreation) {
rowItem.creation = newCreation
},
},
computed: {
slotName() {
return slotNames[this.slotIndex]
},
},
}
</script>

View File

@ -0,0 +1,35 @@
<template>
<div class="component-select-users-table">
<b-table-lite :items="items" :fields="fields" caption-top striped hover stacked="md">
<template #cell(bookmark)="row">
<div>
<b-button
v-if="row.item.emailChecked"
variant="warning"
size="md"
@click="$emit('push-item', row.item)"
class="mr-2"
>
<b-icon icon="plus" variant="success"></b-icon>
</b-button>
<div v-else>{{ $t('e_mail') }}!</div>
</div>
</template>
</b-table-lite>
</div>
</template>
<script>
export default {
name: 'SelectUsersTable',
props: {
items: {
type: Array,
required: true,
},
fields: {
type: Array,
required: true,
},
},
}
</script>

View File

@ -0,0 +1,26 @@
<template>
<div class="component-selected-users-table">
<b-table-lite :items="items" :fields="fields" caption-top striped hover stacked="md">
<template #cell(bookmark)="row">
<b-button variant="danger" size="md" @click="$emit('remove-item', row.item)" class="mr-2">
<b-icon icon="x" variant="light"></b-icon>
</b-button>
</template>
</b-table-lite>
</div>
</template>
<script>
export default {
name: 'SelectedUsersTable',
props: {
items: {
type: Array,
required: true,
},
fields: {
type: Array,
required: true,
},
},
}
</script>

View File

@ -1,225 +0,0 @@
import { mount } from '@vue/test-utils'
import UserTable from './UserTable.vue'
const localVue = global.localVue
const apolloQueryMock = jest.fn()
apolloQueryMock.mockResolvedValue()
describe('UserTable', () => {
let wrapper
const defaultItemsUser = [
{
email: 'bibi@bloxberg.de',
firstName: 'Bibi',
lastName: 'Bloxberg',
creation: [1000, 1000, 1000],
},
{
email: 'bibi@bloxberg.de',
firstName: 'Bibi',
lastName: 'Bloxberg',
creation: [1000, 1000, 1000],
},
{
email: 'bibi@bloxberg.de',
firstName: 'Bibi',
lastName: 'Bloxberg',
creation: [1000, 1000, 1000],
},
]
const confirmationItemsUser = [
{
email: 'bibi@bloxberg.de',
firstName: 'Bibi',
lastName: 'Bloxberg',
amount: 10,
memo: 'Test 1',
date: '11-09-2001',
moderator: 1,
},
{
email: 'bibi@bloxberg.de',
firstName: 'Bibi',
lastName: 'Bloxberg',
amount: 10,
memo: 'Test 2',
date: '21-09-2001',
moderator: 1,
},
{
email: 'bibi@bloxberg.de',
firstName: 'Bibi',
lastName: 'Bloxberg',
amount: 10,
memo: 'Test 3',
date: '30-09-2001',
moderator: 1,
},
]
const propsDataPageUserSearch = {
type: 'PageUserSearch',
itemsUser: defaultItemsUser,
fieldsTable: [
'email',
'firstName',
'lastName',
'creation',
'show_details',
'confirm_mail',
'transactions_list',
],
}
const propsDataUserListSearch = {
type: 'UserListSearch',
itemsUser: defaultItemsUser,
fieldsTable: ['bookmark', 'email', 'firstName', 'lastName', 'creation'],
creation: [1000, 1000, 1000],
}
const propsDataUserListMassCreation = {
type: 'UserListMassCreation',
itemsUser: defaultItemsUser,
fieldsTable: ['email', 'firstName', 'lastName', 'creation', 'bookmark'],
creation: [1000, 1000, 1000],
}
const propsDataPageCreationConfirm = {
type: 'PageCreationConfirm',
itemsUser: confirmationItemsUser,
fieldsTable: [
'bookmark',
'email',
'firstName',
'lastName',
'amount',
'memo',
'date',
'moderator',
'edit_creation',
'confirm',
],
}
const mocks = {
$t: jest.fn((t) => t),
$d: jest.fn((d) => d),
$apollo: {
query: apolloQueryMock,
},
$store: {
commit: jest.fn(),
},
}
const Wrapper = (propsData) => {
return mount(UserTable, { localVue, propsData, mocks })
}
describe('mount', () => {
describe('type PageUserSearch', () => {
beforeEach(() => {
wrapper = Wrapper(propsDataPageUserSearch)
})
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
it('has a DIV element with the id overlay that is not displayed', () => {
expect(wrapper.find('#overlay').exists()).toBeTruthy()
expect(wrapper.find('#overlay').attributes('style')).toBe('display: none;')
})
describe('table', () => {
it('has a table', () => {
expect(wrapper.find('table').exists()).toBeTruthy()
})
describe('header definition', () => {
it('has 4 column', () => {
expect(wrapper.findAll('th').length).toBe(7)
})
it('has Email as first column', () => {
expect(wrapper.find('th[aria-colindex="1"] div').text()).toBe('Email')
})
it('has First Name as second column', () => {
expect(wrapper.find('th[aria-colindex="2"] div').text()).toBe('First Name')
})
it('has Last Name as third column', () => {
expect(wrapper.find('th[aria-colindex="3"] div').text()).toBe('Last Name')
})
it('has Creation as fourth column', () => {
expect(wrapper.find('th[aria-colindex="4"] div').text()).toBe('Creation')
})
it('has Creation as fifth column', () => {
expect(wrapper.find('th[aria-colindex="5"] div').text()).toBe('Show Details')
})
it('has Creation as sixth column', () => {
expect(wrapper.find('th[aria-colindex="6"] div').text()).toBe('Confirm Mail')
})
it('has Creation as seventh column', () => {
expect(wrapper.find('th[aria-colindex="7"] div').text()).toBe('Transactions List')
})
})
describe('content', () => {
it('has 3 rows', () => {
expect(wrapper.findAll('tbody tr').length).toBe(3)
})
it('has 7 columns', () => {
expect(wrapper.findAll('tr:nth-child(1) > td').length).toBe(7)
})
it('find button on fifth column', () => {
expect(
wrapper.findAll('tr:nth-child(1) > td').at(5).find('button').isVisible(),
).toBeTruthy()
})
})
})
})
describe('type UserListSearch', () => {
beforeEach(() => {
wrapper = Wrapper(propsDataUserListSearch)
})
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
})
describe('type UserListMassCreation', () => {
beforeEach(() => {
wrapper = Wrapper(propsDataUserListMassCreation)
})
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
})
describe('type PageCreationConfirm', () => {
beforeEach(() => {
wrapper = Wrapper(propsDataPageCreationConfirm)
})
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
})
})
})

View File

@ -1,336 +0,0 @@
<template>
<div class="component-user-table">
<div v-show="overlay" id="overlay" class="">
<b-jumbotron class="bg-light p-4">
<template #header>{{ overlayText.header }}</template>
<template #lead>
{{ overlayText.text1 }}
</template>
<hr class="my-4" />
<p>
{{ overlayText.text2 }}
</p>
<b-button size="md" variant="danger" class="m-3" @click="overlayCancel">
{{ overlayText.button_cancel }}
</b-button>
<b-button
size="md"
variant="success"
class="m-3 text-right"
@click="overlayOK(overlayBookmarkType, overlayItem)"
>
{{ overlayText.button_ok }}
</b-button>
</b-jumbotron>
</div>
<b-table-lite
:items="itemsUser"
:fields="fieldsTable"
:filter="criteria"
caption-top
striped
hover
stacked="md"
>
<template #cell(creation)="data">
<div v-html="data.value"></div>
</template>
<template #cell(edit_creation)="row">
<b-button variant="info" size="md" @click="rowToogleDetails(row, 0)" class="mr-2">
<b-icon :icon="row.detailsShowing ? 'x' : 'pencil-square'" aria-label="Help"></b-icon>
</b-button>
</template>
<template #cell(show_details)="row">
<b-button
variant="info"
size="md"
v-if="row.item.emailChecked"
@click="rowToogleDetails(row, 0)"
class="mr-2"
>
<b-icon :icon="row.detailsShowing ? 'eye-slash-fill' : 'eye-fill'"></b-icon>
</b-button>
</template>
<template #cell(confirm_mail)="row">
<b-button
:variant="row.item.emailChecked ? 'success' : 'danger'"
size="md"
@click="rowToogleDetails(row, 1)"
class="mr-2"
>
<b-icon
:icon="row.item.emailChecked ? 'envelope-open' : 'envelope'"
aria-label="Help"
></b-icon>
</b-button>
</template>
<template #cell(transactions_list)="row">
<b-button variant="warning" size="md" @click="rowToogleDetails(row, 2)" class="mr-2">
<b-icon icon="list"></b-icon>
</b-button>
</template>
<template #row-details="row">
<row-details
v-if="type !== 'UserListSearch' && type !== 'UserListMassCreation'"
:row="row"
:type="type"
:slotName="slotName"
:index="slotIndex"
@row-toogle-details="rowToogleDetails"
>
<template #show-creation>
<div>
<creation-formular
v-if="type === 'PageUserSearch'"
type="singleCreation"
:pagetype="type"
:creation="row.item.creation"
:item="row.item"
:creationUserData="creationUserData"
@update-creation-data="updateCreationData"
@update-user-data="updateUserData"
/>
<edit-creation-formular
v-else
type="singleCreation"
:pagetype="type"
:creation="row.item.creation"
:item="row.item"
:row="row"
:creationUserData="creationUserData"
@update-creation-data="updateCreationData"
@update-user-data="updateUserData"
/>
</div>
</template>
<template #show-register-mail>
<confirm-register-mail-formular
:checked="row.item.emailChecked"
:email="row.item.email"
:dateLastSend="$d(new Date(), 'long')"
/>
</template>
<template #show-transaction-list>
<creation-transaction-list-formular :userId="row.item.userId" />
</template>
</row-details>
</template>
<template #cell(bookmark)="row">
<div v-show="type === 'UserListSearch'">
<b-button
v-if="row.item.emailChecked"
variant="warning"
size="md"
@click="bookmarkPush(row.item)"
class="mr-2"
>
<b-icon icon="plus" variant="success"></b-icon>
</b-button>
<div v-else>{{ $t('e_mail') }}!</div>
</div>
<b-button
variant="danger"
v-show="type === 'UserListMassCreation' || type === 'PageCreationConfirm'"
size="md"
@click="overlayShow('remove', row.item)"
class="mr-2"
>
<b-icon icon="x" variant="light"></b-icon>
</b-button>
</template>
<template #cell(confirm)="row">
<b-button
variant="success"
v-show="type === 'PageCreationConfirm'"
size="md"
@click="overlayShow('confirm', row.item)"
class="mr-2"
>
<b-icon icon="check" scale="2" variant=""></b-icon>
</b-button>
</template>
</b-table-lite>
</div>
</template>
<script>
import CreationFormular from '../components/CreationFormular.vue'
import EditCreationFormular from '../components/EditCreationFormular.vue'
import ConfirmRegisterMailFormular from '../components/ConfirmRegisterMailFormular.vue'
import CreationTransactionListFormular from '../components/CreationTransactionListFormular.vue'
import RowDetails from '../components/RowDetails.vue'
const slotNames = ['show-creation', 'show-register-mail', 'show-transaction-list']
export default {
name: 'UserTable',
props: {
type: {
type: String,
required: true,
},
itemsUser: {
type: Array,
required: true,
},
fieldsTable: {
type: Array,
required: true,
},
criteria: {
type: String,
required: false,
default: '',
},
creation: {
type: Array,
required: false,
},
},
components: {
CreationFormular,
EditCreationFormular,
ConfirmRegisterMailFormular,
CreationTransactionListFormular,
RowDetails,
},
data() {
return {
showCreationFormular: null,
showConfirmRegisterMailFormular: null,
showCreationTransactionListFormular: null,
creationUserData: {},
overlay: false,
overlayBookmarkType: '',
overlayItem: [],
overlayText: [
{
header: '-',
text1: '--',
text2: '---',
button_ok: 'OK',
button_cancel: 'Cancel',
},
],
slotIndex: 0,
openRow: null,
}
},
methods: {
rowToogleDetails(row, index) {
if (this.openRow) {
if (this.openRow.index === row.index) {
if (index === this.slotIndex) {
row.toggleDetails()
this.openRow = null
} else {
this.slotIndex = index
}
} else {
this.openRow.toggleDetails()
row.toggleDetails()
this.slotIndex = index
this.openRow = row
if (this.type === 'PageCreationConfirm') {
this.creationUserData = row.item
}
}
} else {
row.toggleDetails()
this.slotIndex = index
this.openRow = row
if (this.type === 'PageCreationConfirm') {
this.creationUserData = row.item
}
}
},
overlayShow(bookmarkType, item) {
this.overlay = true
this.overlayBookmarkType = bookmarkType
this.overlayItem = item
if (bookmarkType === 'remove') {
this.overlayText.header = this.$t('overlay.remove.title')
this.overlayText.text1 = this.$t('overlay.remove.text')
this.overlayText.text2 = this.$t('overlay.remove.question')
this.overlayText.button_ok = this.$t('overlay.remove.yes')
this.overlayText.button_cancel = this.$t('overlay.remove.no')
}
if (bookmarkType === 'confirm') {
this.overlayText.header = this.$t('overlay.confirm.title')
this.overlayText.text1 = this.$t('overlay.confirm.text')
this.overlayText.text2 = this.$t('overlay.confirm.question')
this.overlayText.button_ok = this.$t('overlay.confirm.yes')
this.overlayText.button_cancel = this.$t('overlay.confirm.no')
}
},
overlayOK(bookmarkType, item) {
if (bookmarkType === 'remove') {
this.bookmarkRemove(item)
}
if (bookmarkType === 'confirm') {
this.$emit('confirm-creation', item)
}
this.overlay = false
},
overlayCancel() {
this.overlay = false
},
bookmarkPush(item) {
this.$emit('push-item', item)
},
bookmarkRemove(item) {
if (this.type === 'UserListMassCreation') {
this.$emit('remove-item', item)
}
if (this.type === 'PageCreationConfirm') {
this.$emit('remove-creation', item)
}
},
updateCreationData(data) {
this.creationUserData.amount = data.amount
this.creationUserData.date = data.date
this.creationUserData.memo = data.memo
this.creationUserData.moderator = data.moderator
data.row.toggleDetails()
},
updateUserData(rowItem, newCreation) {
rowItem.creation = newCreation
},
},
computed: {
slotName() {
return slotNames[this.slotIndex]
},
},
}
</script>
<style>
#overlay {
position: fixed;
display: flex;
align-items: center;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding-left: 5%;
background-color: rgba(12, 11, 11, 0.781);
z-index: 1000000;
cursor: pointer;
}
</style>

View File

@ -16,6 +16,8 @@ export const searchUsers = gql`
email
creation
emailChecked
hasElopage
emailConfirmationSend
}
}
}

View File

@ -54,9 +54,9 @@ const dateTimeFormats = {
},
long: {
year: 'numeric',
month: 'short',
month: 'long',
day: 'numeric',
weekday: 'short',
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
},
@ -78,9 +78,9 @@ const dateTimeFormats = {
},
long: {
day: 'numeric',
month: 'short',
month: 'long',
year: 'numeric',
weekday: 'short',
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
},

View File

@ -2,6 +2,7 @@
"all_emails": "Alle Nutzer",
"bookmark": "bookmark",
"confirmed": "bestätigt",
"creation": "Schöpfung",
"creation_form": {
"creation_for": "Aktives Grundeinkommen für",
"enter_text": "Text eintragen",
@ -19,12 +20,15 @@
"update_creation": "Schöpfung aktualisieren"
},
"date": "Datum",
"delete": "Löschen",
"details": "Details",
"edit": "Bearbeiten",
"e_mail": "E-Mail",
"firstname": "Vorname",
"gradido_admin_footer": "Gradido Akademie Adminkonsole",
"hide_details": "Details verbergen von",
"lastname": "Nachname",
"moderator": "Moderator",
"multiple_creation_text": "Bitte wähle ein oder mehrere Mitglieder aus für die du Schöpfen möchtest.",
"navbar": {
"logout": "Abmelden",
@ -54,6 +58,9 @@
}
},
"remove": "Entfernen",
"remove_all": "alle Nutzer entfernen",
"save": "Speichern",
"text": "Text",
"transaction": "Transaktion",
"transactionlist": {
"amount": "Betrag",
@ -70,7 +77,7 @@
"info": "Email bestätigen, wiederholt senden an:",
"success": "Erfolgreiches Senden des Bestätigungs-Links an die E-Mail des Nutzers! ({email})",
"text_false": " Die letzte Email wurde am {date} Uhr an das Mitglied ({mail}) gesendet.",
"text_true": " Die Email wurde am {date} Uhr bestätigt."
"text_true": " Die Email wurde bestätigt."
},
"user_search": "Nutzer-Suche"
}

View File

@ -2,6 +2,7 @@
"all_emails": "All users",
"bookmark": "Remember",
"confirmed": "confirmed",
"creation": "Creation",
"creation_form": {
"creation_for": "Active Basic Income for",
"enter_text": "Enter text",
@ -19,12 +20,15 @@
"update_creation": "Creation update"
},
"date": "Date",
"delete": "Delete",
"details": "Details",
"edit": "Edit",
"e_mail": "E-mail",
"firstname": "Firstname",
"gradido_admin_footer": "Gradido Academy Admin Console",
"hide_details": "Hide details from",
"lastname": "Lastname",
"moderator": "Moderator",
"multiple_creation_text": "Please select one or more members for which you would like to perform creations.",
"navbar": {
"logout": "Logout",
@ -54,6 +58,9 @@
}
},
"remove": "Remove",
"remove_all": "Remove all users",
"save": "Speichern",
"text": "Text",
"transaction": "Transaction",
"transactionlist": {
"amount": "Amount",
@ -69,8 +76,8 @@
"error": "Error sending the confirmation link to the user: {message}",
"info": "Confirm email, send repeatedly to:",
"success": "Successfully send the confirmation link to the user's email! ({email})",
"text_false": "The last email was sent to the member ({mail}) on {date} clock.",
"text_true": "The email was confirmed on {date} clock."
"text_false": "The last email was sent to the member ({mail}) on {date}.",
"text_true": "The email was confirmed."
},
"user_search": "User search"
}

View File

@ -1,6 +1,9 @@
export const creationMonths = {
props: {
creation: [1000, 1000, 1000],
creation: {
type: Array,
default: () => [1000, 1000, 1000],
},
},
computed: {
creationDates() {
@ -31,5 +34,8 @@ export const creationMonths = {
}
})
},
creationLabel() {
return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ')
},
},
}

View File

@ -0,0 +1,34 @@
export const toggleRowDetails = {
data() {
return {
slotIndex: 0,
openRow: null,
creationUserData: {},
}
},
methods: {
rowToogleDetails(row, index) {
if (this.openRow) {
if (this.openRow.index === row.index) {
if (index === this.slotIndex) {
row.toggleDetails()
this.openRow = null
} else {
this.slotIndex = index
}
} else {
this.openRow.toggleDetails()
row.toggleDetails()
this.slotIndex = index
this.openRow = row
this.creationUserData = row.item
}
} else {
row.toggleDetails()
this.slotIndex = index
this.openRow = row
this.creationUserData = row.item
}
},
},
}

View File

@ -0,0 +1,141 @@
import { toggleRowDetails } from './toggleRowDetails'
import { mount } from '@vue/test-utils'
const localVue = global.localVue
const Component = {
render() {},
mixins: [toggleRowDetails],
}
const toggleDetailsMock = jest.fn()
const secondToggleDetailsMock = jest.fn()
const row = {
toggleDetails: toggleDetailsMock,
index: 0,
item: {
data: 'item-data',
},
}
let wrapper
describe('toggleRowDetails', () => {
beforeEach(() => {
jest.clearAllMocks()
wrapper = mount(Component, { localVue })
})
it('sets default data', () => {
expect(wrapper.vm.slotIndex).toBe(0)
expect(wrapper.vm.openRow).toBe(null)
expect(wrapper.vm.creationUserData).toEqual({})
})
describe('no open row', () => {
beforeEach(() => {
wrapper.vm.rowToogleDetails(row, 2)
})
it('calls toggleDetails', () => {
expect(toggleDetailsMock).toBeCalled()
})
it('updates slot index', () => {
expect(wrapper.vm.slotIndex).toBe(2)
})
it('updates open row', () => {
expect(wrapper.vm.openRow).toEqual(
expect.objectContaining({
index: 0,
item: {
data: 'item-data',
},
}),
)
})
it('updates creation user data', () => {
expect(wrapper.vm.creationUserData).toEqual({ data: 'item-data' })
})
})
describe('with open row', () => {
beforeEach(() => {
wrapper.setData({ openRow: row })
})
describe('row index is open row index', () => {
describe('index is slot index', () => {
beforeEach(() => {
wrapper.vm.rowToogleDetails(row, 0)
})
it('calls toggleDetails', () => {
expect(toggleDetailsMock).toBeCalled()
})
it('sets open row to null', () => {
expect(wrapper.vm.openRow).toBe(null)
})
})
describe('index is not slot index', () => {
beforeEach(() => {
wrapper.vm.rowToogleDetails(row, 2)
})
it('does not call toggleDetails', () => {
expect(toggleDetailsMock).not.toBeCalled()
})
it('updates slot index', () => {
expect(wrapper.vm.slotIndex).toBe(2)
})
})
})
describe('row index is not open row index', () => {
beforeEach(() => {
wrapper.vm.rowToogleDetails(
{
toggleDetails: secondToggleDetailsMock,
index: 2,
item: {
data: 'new-item-data',
},
},
2,
)
})
it('closes the open row', () => {
expect(toggleDetailsMock).toBeCalled()
})
it('opens the new row', () => {
expect(secondToggleDetailsMock).toBeCalled()
})
it('updates slot index', () => {
expect(wrapper.vm.slotIndex).toBe(2)
})
it('updates open row', () => {
expect(wrapper.vm.openRow).toEqual({
toggleDetails: secondToggleDetailsMock,
index: 2,
item: {
data: 'new-item-data',
},
})
})
it('updates creation user data', () => {
expect(wrapper.vm.creationUserData).toEqual({ data: 'new-item-data' })
})
})
})
})

View File

@ -1,4 +1,4 @@
import { shallowMount } from '@vue/test-utils'
import { mount } from '@vue/test-utils'
import Creation from './Creation.vue'
const localVue = global.localVue
@ -14,6 +14,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
lastName: 'Bloxberg',
email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
emailChecked: true,
},
{
userId: 2,
@ -21,6 +22,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
emailChecked: true,
},
],
},
@ -51,10 +53,10 @@ describe('Creation', () => {
let wrapper
const Wrapper = () => {
return shallowMount(Creation, { localVue, mocks })
return mount(Creation, { localVue, mocks })
}
describe('shallowMount', () => {
describe('mount', () => {
beforeEach(() => {
jest.clearAllMocks()
wrapper = Wrapper()
@ -77,64 +79,66 @@ describe('Creation', () => {
)
})
it('sets the data of itemsList', () => {
expect(wrapper.vm.itemsList).toEqual([
{
userId: 1,
firstName: 'Bibi',
lastName: 'Bloxberg',
email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
showDetails: false,
},
{
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
},
])
it('has two rows in the left table', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2)
})
it('has nwo rows in the right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0)
})
it('has correct data in first row ', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain('Bibi')
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain(
'Bloxberg',
)
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain(
'200 | 400 | 600',
)
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain(
'bibi@bloxberg.de',
)
})
it('has correct data in second row ', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain(
'Benjamin',
)
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain(
'Blümchen',
)
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain(
'800 | 600 | 400',
)
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).text()).toContain(
'benjamin@bluemchen.de',
)
})
})
describe('push item', () => {
beforeEach(() => {
wrapper.findComponent({ name: 'UserTable' }).vm.$emit('push-item', {
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
})
wrapper.findAll('table').at(0).findAll('tbody > tr').at(1).find('button').trigger('click')
})
it('removes the pushed item from itemsList', () => {
expect(wrapper.vm.itemsList).toEqual([
{
userId: 1,
firstName: 'Bibi',
lastName: 'Bloxberg',
email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
showDetails: false,
},
])
it('has one item in left table', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(1)
})
it('adds the pushed item to itemsMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([
{
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
},
])
it('has one item in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(1)
})
it('has the correct user in left table', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain(
'bibi@bloxberg.de',
)
})
it('has the correct user in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr').at(0).text()).toContain(
'benjamin@bluemchen.de',
)
})
it('updates userSelectedInMassCreation in store', () => {
@ -146,88 +150,58 @@ describe('Creation', () => {
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
},
])
})
})
describe('remove item', () => {
beforeEach(async () => {
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('push-item', {
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
})
await wrapper
.findAllComponents({ name: 'UserTable' })
.at(1)
.vm.$emit('remove-item', {
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
})
})
it('adds the removed item to itemsList', () => {
expect(wrapper.vm.itemsList).toEqual([
{
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
},
{
userId: 1,
firstName: 'Bibi',
lastName: 'Bloxberg',
email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
showDetails: false,
emailChecked: true,
},
])
})
it('removes the item from itemsMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([])
})
it('commits empty array as userSelectedInMassCreation', () => {
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
})
})
describe('remove all bookmarks', () => {
beforeEach(async () => {
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('push-item', {
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
describe('remove item', () => {
beforeEach(async () => {
await wrapper
.findAll('table')
.at(1)
.findAll('tbody > tr')
.at(0)
.find('button')
.trigger('click')
})
it('has two items in left table', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2)
})
it('has the removed user in first row', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr').at(0).text()).toContain(
'benjamin@bluemchen.de',
)
})
it('has no items in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0)
})
it('commits empty array as userSelectedInMassCreation', () => {
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
})
jest.clearAllMocks()
wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark')
})
it('removes all items from itemsMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([])
})
describe('remove all bookmarks', () => {
beforeEach(async () => {
jest.clearAllMocks()
await wrapper.find('button.btn-light').trigger('click')
})
it('commits empty array to userSelectedInMassCreation', () => {
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
})
it('has no items in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0)
})
it('calls searchUsers', () => {
expect(apolloQueryMock).toBeCalled()
it('commits empty array to userSelectedInMassCreation', () => {
expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', [])
})
it('calls searchUsers', () => {
expect(apolloQueryMock).toBeCalled()
})
})
})
@ -241,22 +215,24 @@ describe('Creation', () => {
email: 'benjamin@bluemchen.de',
creation: [800, 600, 400],
showDetails: false,
emailChecked: true,
},
]
wrapper = Wrapper()
})
it('has only one item itemsList', () => {
expect(wrapper.vm.itemsList).toEqual([
{
userId: 1,
firstName: 'Bibi',
lastName: 'Bloxberg',
email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
showDetails: false,
},
])
it('has one item in left table', () => {
expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(1)
})
it('has one item in right table', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(1)
})
it('has the stored user in second row', () => {
expect(wrapper.findAll('table').at(1).findAll('tbody > tr').at(0).text()).toContain(
'benjamin@bluemchen.de',
)
})
})
@ -265,17 +241,38 @@ describe('Creation', () => {
jest.clearAllMocks()
})
it('calls API when criteria changes', async () => {
await wrapper.setData({ criteria: 'XX' })
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: 'XX',
currentPage: 1,
pageSize: 25,
},
}),
)
describe('search criteria', () => {
beforeEach(async () => {
await wrapper.setData({ criteria: 'XX' })
})
it('calls API when criteria changes', async () => {
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: 'XX',
currentPage: 1,
pageSize: 25,
},
}),
)
})
describe('reset search criteria', () => {
it('calls the API', async () => {
jest.clearAllMocks()
await wrapper.find('.test-click-clear-criteria').trigger('click')
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 1,
pageSize: 25,
},
}),
)
})
})
})
it('calls API when currentPage changes', async () => {

View File

@ -3,19 +3,24 @@
<b-row>
<b-col cols="12" lg="6">
<label>Usersuche</label>
<b-input
type="text"
v-model="criteria"
class="shadow p-3 mb-5 bg-white rounded"
placeholder="User suche"
></b-input>
<user-table
<b-input-group>
<b-form-input
type="text"
class="test-input-criteria"
v-model="criteria"
:placeholder="$t('user_search')"
></b-form-input>
<b-input-group-append class="test-click-clear-criteria" @click="criteria = ''">
<b-input-group-text class="pointer">
<b-icon icon="x" />
</b-input-group-text>
</b-input-group-append>
</b-input-group>
<select-users-table
v-if="itemsList.length > 0"
type="UserListSearch"
:itemsUser="itemsList"
:fieldsTable="Searchfields"
:criteria="criteria"
:creation="creation"
:items="itemsList"
:fields="Searchfields"
@push-item="pushItem"
/>
<b-pagination
@ -27,16 +32,21 @@
></b-pagination>
</b-col>
<b-col cols="12" lg="6" class="shadow p-3 mb-5 rounded bg-info">
<user-table
v-show="itemsMassCreation.length > 0"
class="shadow p-3 mb-5 bg-white rounded"
type="UserListMassCreation"
:itemsUser="itemsMassCreation"
:fieldsTable="fields"
:criteria="null"
:creation="creation"
@remove-item="removeItem"
/>
<div v-show="itemsMassCreation.length > 0">
<div class="text-right pr-4 mb-1">
<b-button @click="removeAllBookmarks()" variant="light">
<b-icon icon="x" scale="2" variant="danger"></b-icon>
{{ $t('remove_all') }}
</b-button>
</div>
<selected-users-table
class="shadow p-3 mb-5 bg-white rounded"
:items="itemsMassCreation"
:fields="fields"
@remove-item="removeItem"
/>
</div>
<div v-if="itemsMassCreation.length === 0">
{{ $t('multiple_creation_text') }}
</div>
@ -45,7 +55,7 @@
type="massCreation"
:creation="creation"
:items="itemsMassCreation"
@remove-all-bookmark="removeAllBookmark"
@remove-all-bookmark="removeAllBookmarks"
/>
</b-col>
</b-row>
@ -53,14 +63,18 @@
</template>
<script>
import CreationFormular from '../components/CreationFormular.vue'
import UserTable from '../components/UserTable.vue'
import SelectUsersTable from '../components/Tables/SelectUsersTable.vue'
import SelectedUsersTable from '../components/Tables/SelectedUsersTable.vue'
import { searchUsers } from '../graphql/searchUsers'
import { creationMonths } from '../mixins/creationMonths'
export default {
name: 'Creation',
mixins: [creationMonths],
components: {
CreationFormular,
UserTable,
SelectUsersTable,
SelectedUsersTable,
},
data() {
return {
@ -69,7 +83,6 @@ export default {
itemsMassCreation: this.$store.state.userSelectedInMassCreation,
radioSelectedMass: '',
criteria: '',
creation: [null, null, null],
rows: 0,
currentPage: 1,
perPage: 25,
@ -126,7 +139,7 @@ export default {
)
this.$store.commit('setUserSelectedInMassCreation', this.itemsMassCreation)
},
removeAllBookmark() {
removeAllBookmarks() {
this.itemsMassCreation = []
this.$store.commit('setUserSelectedInMassCreation', [])
this.getUsers()
@ -163,16 +176,6 @@ export default {
{ key: 'bookmark', label: this.$t('remove') },
]
},
creationLabel() {
const now = new Date(this.now)
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1)
const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1)
return [
this.$d(beforeLastMonth, 'monthShort'),
this.$d(lastMonth, 'monthShort'),
this.$d(now, 'monthShort'),
].join(' | ')
},
},
watch: {
currentPage() {

View File

@ -78,6 +78,7 @@ describe('CreationConfirm', () => {
it('commits resetOpenCreations to store', () => {
expect(storeCommitMock).toBeCalledWith('resetOpenCreations')
})
it('commits setOpenCreations to store', () => {
expect(storeCommitMock).toBeCalledWith('setOpenCreations', 2)
})
@ -85,7 +86,7 @@ describe('CreationConfirm', () => {
describe('remove creation with success', () => {
beforeEach(async () => {
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('remove-creation', { id: 1 })
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
})
it('calls the deletePendingCreation mutation', () => {
@ -107,7 +108,7 @@ describe('CreationConfirm', () => {
describe('remove creation with error', () => {
beforeEach(async () => {
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('remove-creation', { id: 1 })
await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click')
})
it('toasts an error message', () => {
@ -118,33 +119,63 @@ describe('CreationConfirm', () => {
describe('confirm creation with success', () => {
beforeEach(async () => {
apolloMutateMock.mockResolvedValue({})
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('confirm-creation', { id: 2 })
await wrapper.findAll('tr').at(2).findAll('button').at(2).trigger('click')
})
it('calls the confirmPendingCreation mutation', () => {
expect(apolloMutateMock).toBeCalledWith({
mutation: confirmPendingCreation,
variables: { id: 2 },
describe('overlay', () => {
it('opens the overlay', () => {
expect(wrapper.find('#overlay').isVisible()).toBeTruthy()
})
})
it('commits openCreationsMinus to store', () => {
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
})
describe('cancel confirmation', () => {
beforeEach(async () => {
await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
})
it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
})
})
it('closes the overlay', () => {
expect(wrapper.find('#overlay').isVisible()).toBeFalsy()
})
describe('confirm creation with error', () => {
beforeEach(async () => {
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
await wrapper.findComponent({ name: 'UserTable' }).vm.$emit('confirm-creation', { id: 2 })
})
it('still has 2 items in the table', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(2)
})
})
it('toasts an error message', () => {
expect(toastedErrorMock).toBeCalledWith('Ouchhh!')
describe('confirm creation', () => {
beforeEach(async () => {
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
})
it('calls the confirmPendingCreation mutation', () => {
expect(apolloMutateMock).toBeCalledWith({
mutation: confirmPendingCreation,
variables: { id: 2 },
})
})
it('commits openCreationsMinus to store', () => {
expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1)
})
it('toasts a success message', () => {
expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_created')
})
it('has 1 item left in the table', () => {
expect(wrapper.findAll('tbody > tr')).toHaveLength(1)
})
})
describe('confirm creation with error', () => {
beforeEach(async () => {
apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' })
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
})
it('toasts an error message', () => {
expect(toastedErrorMock).toBeCalledWith('Ouchhh!')
})
})
})
})

View File

@ -1,17 +1,30 @@
<template>
<div class="creation-confirm">
<user-table
<div v-show="overlay" id="overlay" class="">
<b-jumbotron class="bg-light p-4">
<template #header>{{ $t('overlay.confirm.title') }}</template>
<template #lead>{{ $t('overlay.confirm.text') }}</template>
<hr class="my-4" />
<p>{{ $t('overlay.confirm.question') }}</p>
<b-button size="md" variant="danger" class="m-3" @click="overlay = false">
{{ $t('overlay.confirm.no') }}
</b-button>
<b-button size="md" variant="success" class="m-3 text-right" @click="confirmCreation">
{{ $t('overlay.confirm.yes') }}
</b-button>
</b-jumbotron>
</div>
<open-creations-table
class="mt-4"
type="PageCreationConfirm"
:itemsUser="pendingCreations"
:fieldsTable="fields"
:items="pendingCreations"
:fields="fields"
@remove-creation="removeCreation"
@confirm-creation="confirmCreation"
@show-overlay="showOverlay"
/>
</div>
</template>
<script>
import UserTable from '../components/UserTable.vue'
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
import { getPendingCreations } from '../graphql/getPendingCreations'
import { deletePendingCreation } from '../graphql/deletePendingCreation'
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
@ -19,11 +32,13 @@ import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
export default {
name: 'CreationConfirm',
components: {
UserTable,
OpenCreationsTable,
},
data() {
return {
pendingCreations: [],
overlay: false,
item: [],
}
},
methods: {
@ -43,19 +58,21 @@ export default {
this.$toasted.error(error.message)
})
},
confirmCreation(item) {
confirmCreation() {
this.$apollo
.mutate({
mutation: confirmPendingCreation,
variables: {
id: item.id,
id: this.item.id,
},
})
.then((result) => {
this.updatePendingCreations(item.id)
this.overlay = false
this.updatePendingCreations(this.item.id)
this.$toasted.success(this.$t('creation_form.toasted_created'))
})
.catch((error) => {
this.overlay = false
this.$toasted.error(error.message)
})
},
@ -78,22 +95,26 @@ export default {
this.pendingCreations = this.pendingCreations.filter((obj) => obj.id !== id)
this.$store.commit('openCreationsMinus', 1)
},
showOverlay(item) {
this.overlay = true
this.item = item
},
},
computed: {
fields() {
return [
{ key: 'bookmark', label: 'löschen' },
{ key: 'email', label: 'Email' },
{ key: 'firstName', label: 'Vorname' },
{ key: 'lastName', label: 'Nachname' },
{ key: 'bookmark', label: this.$t('delete') },
{ key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'amount',
label: 'Schöpfung',
label: this.$t('creation'),
formatter: (value) => {
return value + ' GDD'
},
},
{ key: 'memo', label: 'Text' },
{ key: 'memo', label: this.$t('text') },
{
key: 'date',
label: this.$t('date'),
@ -101,9 +122,9 @@ export default {
return this.$d(new Date(value), 'short')
},
},
{ key: 'moderator', label: 'Moderator' },
{ key: 'edit_creation', label: 'ändern' },
{ key: 'confirm', label: 'speichern' },
{ key: 'moderator', label: this.$t('moderator') },
{ key: 'edit_creation', label: this.$t('edit') },
{ key: 'confirm', label: this.$t('save') },
]
},
},
@ -112,3 +133,20 @@ export default {
},
}
</script>
<style>
#overlay {
position: fixed;
display: flex;
align-items: center;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding-left: 5%;
background-color: rgba(12, 11, 11, 0.781);
z-index: 1000000;
cursor: pointer;
}
</style>

View File

@ -9,10 +9,35 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
userCount: 1,
userList: [
{
userId: 1,
firstName: 'Bibi',
lastName: 'Bloxberg',
email: 'bibi@bloxberg.de',
creation: [200, 400, 600],
emailChecked: true,
},
{
userId: 2,
firstName: 'Benjamin',
lastName: 'Blümchen',
email: 'benjamin@bluemchen.de',
creation: [1000, 1000, 1000],
emailChecked: true,
},
{
userId: 3,
firstName: 'Peter',
lastName: 'Lustig',
email: 'peter@lustig.de',
creation: [0, 0, 0],
emailChecked: true,
},
{
userId: 4,
firstName: 'New',
lastName: 'User',
email: 'new@user.ch',
creation: [1000, 1000, 1000],
emailChecked: false,
},
],
@ -24,7 +49,7 @@ const toastErrorMock = jest.fn()
const mocks = {
$t: jest.fn((t) => t),
$d: jest.fn((d) => d),
$d: jest.fn((d) => String(d)),
$apollo: {
query: apolloQueryMock,
},
@ -42,6 +67,7 @@ describe('UserSearch', () => {
describe('mount', () => {
beforeEach(() => {
jest.clearAllMocks()
wrapper = Wrapper()
})
@ -49,13 +75,90 @@ describe('UserSearch', () => {
expect(wrapper.find('div.user-search').exists()).toBeTruthy()
})
it('calls the API', () => {
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 1,
pageSize: 25,
notActivated: false,
},
}),
)
})
describe('unconfirmed emails', () => {
beforeEach(async () => {
await wrapper.find('button.btn-block').trigger('click')
})
it('filters the users by unconfirmed emails', () => {
expect(wrapper.vm.searchResult).toHaveLength(1)
it('calls API with filter', () => {
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 1,
pageSize: 25,
notActivated: true,
},
}),
)
})
})
describe('pagination', () => {
beforeEach(async () => {
wrapper.setData({ currentPage: 2 })
})
it('calls the API with new page', () => {
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 2,
pageSize: 25,
notActivated: false,
},
}),
)
})
})
describe('user search', () => {
beforeEach(async () => {
wrapper.setData({ criteria: 'search string' })
})
it('calls the API with search string', () => {
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: 'search string',
currentPage: 1,
pageSize: 25,
notActivated: false,
},
}),
)
})
describe('reset the search field', () => {
it('calls the API with empty criteria', async () => {
jest.clearAllMocks()
await wrapper.find('.test-click-clear-criteria').trigger('click')
expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
searchText: '',
currentPage: 1,
pageSize: 25,
notActivated: false,
},
}),
)
})
})
})

View File

@ -7,20 +7,22 @@
</b-button>
</div>
<label>{{ $t('user_search') }}</label>
<b-input
type="text"
v-model="criteria"
class="shadow p-3 mb-3 bg-white rounded"
:placeholder="$t('user_search')"
@input="getUsers"
></b-input>
<user-table
type="PageUserSearch"
:itemsUser="searchResult"
:fieldsTable="fields"
:criteria="criteria"
/>
<div>
<b-input-group>
<b-form-input
type="text"
class="test-input-criteria"
v-model="criteria"
:placeholder="$t('user_search')"
></b-form-input>
<b-input-group-append class="test-click-clear-criteria" @click="criteria = ''">
<b-input-group-text class="pointer">
<b-icon icon="x" />
</b-input-group-text>
</b-input-group-append>
</b-input-group>
</div>
<search-user-table type="PageUserSearch" :items="searchResult" :fields="fields" />
<b-pagination
pills
size="lg"
@ -33,13 +35,15 @@
</div>
</template>
<script>
import UserTable from '../components/UserTable.vue'
import SearchUserTable from '../components/Tables/SearchUserTable.vue'
import { searchUsers } from '../graphql/searchUsers'
import { creationMonths } from '../mixins/creationMonths'
export default {
name: 'UserSearch',
mixins: [creationMonths],
components: {
UserTable,
SearchUserTable,
},
data() {
return {
@ -83,16 +87,11 @@ export default {
currentPage() {
this.getUsers()
},
criteria() {
this.getUsers()
},
},
computed: {
lastMonthDate() {
const now = new Date(this.now)
return new Date(now.getFullYear(), now.getMonth() - 1, 1)
},
beforeLastMonthDate() {
const now = new Date(this.now)
return new Date(now.getFullYear(), now.getMonth() - 2, 1)
},
fields() {
return [
{ key: 'email', label: this.$t('e_mail') },
@ -100,17 +99,14 @@ export default {
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: [
this.$d(this.beforeLastMonthDate, 'monthShort'),
this.$d(this.lastMonthDate, 'monthShort'),
this.$d(this.now, 'monthShort'),
].join(' | '),
label: this.creationLabel,
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'show_details', label: this.$t('details') },
{ key: 'confirm_mail', label: this.$t('confirmed') },
{ key: 'has_elopage', label: 'elopage' },
{ key: 'transactions_list', label: this.$t('transaction') },
]
},

1
backend/.gitignore vendored
View File

@ -1,5 +1,6 @@
/node_modules/
/.env
/.env.bak
/build/
package-json.lock
coverage

View File

@ -1,6 +1,6 @@
{
"name": "gradido-backend",
"version": "1.6.1",
"version": "1.6.5",
"description": "Gradido unified backend providing an API-Service for Gradido Transactions",
"main": "src/index.ts",
"repository": "https://github.com/gradido/gradido/backend",
@ -18,6 +18,7 @@
},
"dependencies": {
"@types/jest": "^27.0.2",
"@types/lodash.clonedeep": "^4.5.6",
"apollo-log": "^1.1.0",
"apollo-server-express": "^2.25.2",
"apollo-server-testing": "^2.25.2",
@ -29,6 +30,7 @@
"graphql": "^15.5.1",
"jest": "^27.2.4",
"jsonwebtoken": "^8.5.1",
"lodash.clonedeep": "^4.5.0",
"module-alias": "^2.2.2",
"moment": "^2.29.1",
"mysql2": "^2.3.0",

View File

@ -7,5 +7,4 @@ export const INALIENABLE_RIGHTS = [
RIGHTS.CREATE_USER,
RIGHTS.SEND_RESET_PASSWORD_EMAIL,
RIGHTS.SET_PASSWORD,
RIGHTS.CHECK_USERNAME,
]

View File

@ -17,7 +17,6 @@ export enum RIGHTS {
SEND_RESET_PASSWORD_EMAIL = 'SEND_RESET_PASSWORD_EMAIL',
SET_PASSWORD = 'SET_PASSWORD',
UPDATE_USER_INFOS = 'UPDATE_USER_INFOS',
CHECK_USERNAME = 'CHECK_USERNAME',
HAS_ELOPAGE = 'HAS_ELOPAGE',
// Admin
SEARCH_USERS = 'SEARCH_USERS',

View File

@ -4,7 +4,7 @@ import dotenv from 'dotenv'
dotenv.config()
const constants = {
DB_VERSION: '0016-transaction_signatures',
DB_VERSION: '0021-elopagebuys_fields_nullable',
DECAY_START_TIME: new Date('2021-05-13 17:46:31'), // GMT+0
}

View File

@ -1,7 +0,0 @@
import { ArgsType, Field } from 'type-graphql'
@ArgsType()
export default class CheckUsernameArgs {
@Field(() => String)
username: string
}

View File

@ -8,12 +8,6 @@ export default class UpdateUserInfosArgs {
@Field({ nullable: true })
lastName?: string
@Field({ nullable: true })
description?: string
@Field({ nullable: true })
username?: string
@Field({ nullable: true })
language?: string

View File

@ -5,10 +5,10 @@ import { AuthChecker } from 'type-graphql'
import { decode, encode } from '../../auth/JWT'
import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '../../auth/ROLES'
import { RIGHTS } from '../../auth/RIGHTS'
import { ServerUserRepository } from '../../typeorm/repository/ServerUser'
import { getCustomRepository } from '@dbTools/typeorm'
import { UserRepository } from '../../typeorm/repository/User'
import { INALIENABLE_RIGHTS } from '../../auth/INALIENABLE_RIGHTS'
import { ServerUser } from '@entity/ServerUser'
const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
context.role = ROLE_UNAUTHORIZED // unauthorized user
@ -38,8 +38,7 @@ const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
// TODO this implementation is bullshit - two database queries cause our user identifiers are not aligned and vary between email, id and pubKey
const userRepository = await getCustomRepository(UserRepository)
const user = await userRepository.findByPubkeyHex(context.pubKey)
const serverUserRepository = await getCustomRepository(ServerUserRepository)
const countServerUsers = await serverUserRepository.count({ email: user.email })
const countServerUsers = await ServerUser.count({ email: user.email })
context.role = countServerUsers > 0 ? ROLE_ADMIN : ROLE_USER
context.setHeaders.push({ key: 'token', value: encode(decoded.pubKey) })

View File

@ -13,8 +13,8 @@ export class TransactionList {
this.decayDate = ''
}
@Field(() => Number)
gdtSum: number
@Field(() => Number, { nullable: true })
gdtSum: number | null
@Field(() => Number)
count: number

View File

@ -16,8 +16,6 @@ export class User {
this.email = json.email
this.firstName = json.first_name
this.lastName = json.last_name
this.username = json.username
this.description = json.description
this.pubkey = json.public_hex
this.language = json.language
this.publisherId = json.publisher_id
@ -37,12 +35,6 @@ export class User {
@Field(() => String)
lastName: string
@Field(() => String, { nullable: true })
username?: string
@Field(() => String, { nullable: true })
description?: string
@Field(() => String)
pubkey: string
/*
@ -55,9 +47,6 @@ export class User {
@Field(() =>>> Boolean)
emailChecked: boolean
@Field(() => Boolean)
passphraseShown: boolean
*/
@Field(() => String)
@ -68,10 +57,6 @@ export class User {
disabled: boolean
*/
/* I suggest to have a group as type here
@Field(() => ID)
groupId: number
*/
// what is publisherId?
@Field(() => Int, { nullable: true })
publisherId?: number

View File

@ -19,6 +19,12 @@ export class UserAdmin {
@Field(() => Boolean)
emailChecked: boolean
@Field(() => Boolean)
hasElopage: boolean
@Field(() => String, { nullable: true })
emailConfirmationSend?: string
}
@ObjectType()

View File

@ -9,7 +9,6 @@ import { CreatePendingCreations } from '../model/CreatePendingCreations'
import { UpdatePendingCreation } from '../model/UpdatePendingCreation'
import { RIGHTS } from '../../auth/RIGHTS'
import { TransactionRepository } from '../../typeorm/repository/Transaction'
import { TransactionCreationRepository } from '../../typeorm/repository/TransactionCreation'
import { UserRepository } from '../../typeorm/repository/User'
import CreatePendingCreationArgs from '../arg/CreatePendingCreationArgs'
import UpdatePendingCreationArgs from '../arg/UpdatePendingCreationArgs'
@ -21,8 +20,12 @@ import { UserTransaction } from '@entity/UserTransaction'
import { UserTransactionRepository } from '../../typeorm/repository/UserTransaction'
import { BalanceRepository } from '../../typeorm/repository/Balance'
import { calculateDecay } from '../../util/decay'
import { LoginUserRepository } from '../../typeorm/repository/LoginUser'
import { AdminPendingCreation } from '@entity/AdminPendingCreation'
import { hasElopageBuys } from '../../util/hasElopageBuys'
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
// const EMAIL_OPT_IN_REGISTER = 1
// const EMAIL_OPT_UNKNOWN = 3 // elopage?
@Resolver()
export class AdminResolver {
@ -41,7 +44,28 @@ export class AdminResolver {
adminUser.lastName = user.lastName
adminUser.email = user.email
adminUser.creation = await getUserCreations(user.id)
adminUser.emailChecked = await hasActivatedEmail(user.email)
adminUser.emailChecked = user.emailChecked
adminUser.hasElopage = await hasElopageBuys(user.email)
if (!user.emailChecked) {
const emailOptIn = await LoginEmailOptIn.findOne(
{
userId: user.id,
},
{
order: {
updatedAt: 'DESC',
createdAt: 'DESC',
},
},
)
if (emailOptIn) {
if (emailOptIn.updatedAt) {
adminUser.emailConfirmationSend = emailOptIn.updatedAt.toISOString()
} else {
adminUser.emailConfirmationSend = emailOptIn.createdAt.toISOString()
}
}
}
return adminUser
}),
)
@ -60,8 +84,7 @@ export class AdminResolver {
): Promise<number[]> {
const userRepository = getCustomRepository(UserRepository)
const user = await userRepository.findByEmail(email)
const isActivated = await hasActivatedEmail(user.email)
if (!isActivated) {
if (!user.emailChecked) {
throw new Error('Creation could not be saved, Email is not activated')
}
const creations = await getUserCreations(user.id)
@ -198,13 +221,12 @@ export class AdminResolver {
transaction = await transactionRepository.save(transaction)
if (!transaction) throw new Error('Could not create transaction')
const transactionCreationRepository = getCustomRepository(TransactionCreationRepository)
let transactionCreation = new TransactionCreation()
transactionCreation.transactionId = transaction.id
transactionCreation.userId = pendingCreation.userId
transactionCreation.amount = parseInt(pendingCreation.amount.toString())
transactionCreation.targetDate = pendingCreation.date
transactionCreation = await transactionCreationRepository.save(transactionCreation)
transactionCreation = await TransactionCreation.save(transactionCreation)
if (!transactionCreation) throw new Error('Could not create transactionCreation')
const userTransactionRepository = getCustomRepository(UserTransactionRepository)
@ -256,9 +278,7 @@ async function getUserCreations(id: number): Promise<number[]> {
const lastMonthNumber = moment().subtract(1, 'month').format('M')
const currentMonthNumber = moment().format('M')
const transactionCreationRepository = getCustomRepository(TransactionCreationRepository)
const createdAmountsQuery = await transactionCreationRepository
.createQueryBuilder('transaction_creations')
const createdAmountsQuery = await TransactionCreation.createQueryBuilder('transaction_creations')
.select('MONTH(transaction_creations.target_date)', 'target_month')
.addSelect('SUM(transaction_creations.amount)', 'sum')
.where('transaction_creations.state_user_id = :id', { id })
@ -376,9 +396,3 @@ function isCreationValid(creations: number[], amount: number, creationDate: Date
}
return true
}
async function hasActivatedEmail(email: string): Promise<boolean> {
const repository = getCustomRepository(LoginUserRepository)
const user = await repository.findByEmail(email)
return user ? user.emailChecked : false
}

View File

@ -25,13 +25,17 @@ export class GdtResolver {
const userRepository = getCustomRepository(UserRepository)
const userEntity = await userRepository.findByPubkeyHex(context.pubKey)
const resultGDT = await apiGet(
`${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${userEntity.email}/${currentPage}/${pageSize}/${order}`,
)
if (!resultGDT.success) {
throw new Error(resultGDT.data)
try {
const resultGDT = await apiGet(
`${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${userEntity.email}/${currentPage}/${pageSize}/${order}`,
)
if (!resultGDT.success) {
throw new Error(resultGDT.data)
}
return new GdtEntryList(resultGDT.data)
} catch (err: any) {
throw new Error('GDT Server is not reachable.')
}
return new GdtEntryList(resultGDT.data)
}
@Authorized([RIGHTS.EXIST_PID])

View File

@ -33,7 +33,6 @@ import { calculateDecay } from '../../util/decay'
import { TransactionTypeId } from '../enum/TransactionTypeId'
import { TransactionType } from '../enum/TransactionType'
import { hasUserAmount, isHexPublicKey } from '../../util/validate'
import { LoginUserRepository } from '../../typeorm/repository/LoginUser'
import { RIGHTS } from '../../auth/RIGHTS'
// Helper function
@ -274,14 +273,13 @@ async function addUserTransaction(
}
async function getPublicKey(email: string): Promise<string | null> {
const loginUserRepository = getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findOne({ email: email })
const user = await dbUser.findOne({ email: email })
// User not found
if (!loginUser) {
if (!user) {
return null
}
return loginUser.pubKey.toString('hex')
return user.pubKey.toString('hex')
}
@Resolver()
@ -317,11 +315,13 @@ export class TransactionResolver {
)
// get gdt sum
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
email: userEntity.email,
})
if (!resultGDTSum.success) throw new Error(resultGDTSum.data)
transactions.gdtSum = Number(resultGDTSum.data.sum) || 0
transactions.gdtSum = null
try {
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
email: userEntity.email,
})
if (resultGDTSum.success) transactions.gdtSum = Number(resultGDTSum.data.sum) || 0
} catch (err: any) {}
// get balance
const balanceRepository = getCustomRepository(BalanceRepository)
@ -348,7 +348,7 @@ export class TransactionResolver {
// validate sender user (logged in)
const userRepository = getCustomRepository(UserRepository)
const senderUser = await userRepository.findByPubkeyHex(context.pubKey)
if (senderUser.pubkey.length !== 32) {
if (senderUser.pubKey.length !== 32) {
throw new Error('invalid sender public key')
}
if (!hasUserAmount(senderUser, amount)) {
@ -359,7 +359,7 @@ export class TransactionResolver {
// TODO: the detour over the public key is unnecessary
const recipiantPublicKey = await getPublicKey(email)
if (!recipiantPublicKey) {
throw new Error('recipiant not known')
throw new Error('recipient not known')
}
if (!isHexPublicKey(recipiantPublicKey)) {
throw new Error('invalid recipiant public key')
@ -438,7 +438,7 @@ export class TransactionResolver {
const transactionSendCoin = new dbTransactionSendCoin()
transactionSendCoin.transactionId = transaction.id
transactionSendCoin.userId = senderUser.id
transactionSendCoin.senderPublic = senderUser.pubkey
transactionSendCoin.senderPublic = senderUser.pubKey
transactionSendCoin.recipiantUserId = recipiantUser.id
transactionSendCoin.recipiantPublic = Buffer.from(recipiantPublicKey, 'hex')
transactionSendCoin.amount = centAmount

View File

@ -8,26 +8,21 @@ import CONFIG from '../../config'
import { User } from '../model/User'
import { User as DbUser } from '@entity/User'
import { encode } from '../../auth/JWT'
import CheckUsernameArgs from '../arg/CheckUsernameArgs'
import CreateUserArgs from '../arg/CreateUserArgs'
import UnsecureLoginArgs from '../arg/UnsecureLoginArgs'
import UpdateUserInfosArgs from '../arg/UpdateUserInfosArgs'
import { klicktippNewsletterStateMiddleware } from '../../middleware/klicktippMiddleware'
import { UserSettingRepository } from '../../typeorm/repository/UserSettingRepository'
import { LoginUserRepository } from '../../typeorm/repository/LoginUser'
import { Setting } from '../enum/Setting'
import { UserRepository } from '../../typeorm/repository/User'
import { LoginUser } from '@entity/LoginUser'
import { LoginUserBackup } from '@entity/LoginUserBackup'
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
import { sendResetPasswordEmail } from '../../mailer/sendResetPasswordEmail'
import { sendAccountActivationEmail } from '../../mailer/sendAccountActivationEmail'
import { LoginElopageBuysRepository } from '../../typeorm/repository/LoginElopageBuys'
import { klicktippSignIn } from '../../apis/KlicktippController'
import { RIGHTS } from '../../auth/RIGHTS'
import { ServerUserRepository } from '../../typeorm/repository/ServerUser'
import { ROLE_ADMIN } from '../../auth/ROLES'
import { randomBytes } from 'crypto'
import { hasElopageBuys } from '../../util/hasElopageBuys'
import { ServerUser } from '@entity/ServerUser'
const EMAIL_OPT_IN_RESET_PASSWORD = 2
const EMAIL_OPT_IN_REGISTER = 1
@ -186,10 +181,10 @@ const createEmailOptIn = async (
return emailOptIn
}
const getOptInCode = async (loginUser: LoginUser): Promise<LoginEmailOptIn> => {
const getOptInCode = async (loginUserId: number): Promise<LoginEmailOptIn> => {
const loginEmailOptInRepository = await getRepository(LoginEmailOptIn)
let optInCode = await loginEmailOptInRepository.findOne({
userId: loginUser.id,
userId: loginUserId,
emailOptInTypeId: EMAIL_OPT_IN_RESET_PASSWORD,
})
@ -207,7 +202,7 @@ const getOptInCode = async (loginUser: LoginUser): Promise<LoginEmailOptIn> => {
} else {
optInCode = new LoginEmailOptIn()
optInCode.verificationCode = random(64)
optInCode.userId = loginUser.id
optInCode.userId = loginUserId
optInCode.emailOptInTypeId = EMAIL_OPT_IN_RESET_PASSWORD
}
await loginEmailOptInRepository.save(optInCode)
@ -223,17 +218,13 @@ export class UserResolver {
// TODO refactor and do not have duplicate code with login(see below)
const userRepository = getCustomRepository(UserRepository)
const userEntity = await userRepository.findByPubkeyHex(context.pubKey)
const loginUserRepository = getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findByEmail(userEntity.email)
const user = new User()
user.id = userEntity.id
user.email = userEntity.email
user.firstName = userEntity.firstName
user.lastName = userEntity.lastName
user.username = userEntity.username
user.description = loginUser.description
user.pubkey = userEntity.pubkey.toString('hex')
user.language = loginUser.language
user.pubkey = userEntity.pubKey.toString('hex')
user.language = userEntity.language
// Elopage Status & Stored PublisherId
user.hasElopage = await this.hasElopage(context)
@ -259,89 +250,60 @@ export class UserResolver {
@Ctx() context: any,
): Promise<User> {
email = email.trim().toLowerCase()
const loginUserRepository = getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findByEmail(email).catch(() => {
const dbUser = await DbUser.findOneOrFail({ email }).catch(() => {
throw new Error('No user with this credentials')
})
if (!loginUser.emailChecked) {
if (!dbUser.emailChecked) {
throw new Error('User email not validated')
}
if (loginUser.password === BigInt(0)) {
if (dbUser.password === BigInt(0)) {
// TODO we want to catch this on the frontend and ask the user to check his emails or resend code
throw new Error('User has no password set yet')
}
if (!loginUser.pubKey || !loginUser.privKey) {
if (!dbUser.pubKey || !dbUser.privKey) {
// TODO we want to catch this on the frontend and ask the user to check his emails or resend code
throw new Error('User has no private or publicKey')
}
const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
const loginUserPassword = BigInt(loginUser.password.toString())
const loginUserPassword = BigInt(dbUser.password.toString())
if (loginUserPassword !== passwordHash[0].readBigUInt64LE()) {
throw new Error('No user with this credentials')
}
// TODO: If user has no pubKey Create it again and update user.
const userRepository = getCustomRepository(UserRepository)
let userEntity: void | DbUser
const loginUserPubKey = loginUser.pubKey
const loginUserPubKeyString = loginUserPubKey.toString('hex')
userEntity = await userRepository.findByPubkeyHex(loginUserPubKeyString).catch(() => {
// User not stored in state_users
// TODO: Check with production data - email is unique which can cause problems
userEntity = new DbUser()
userEntity.firstName = loginUser.firstName
userEntity.lastName = loginUser.lastName
userEntity.username = loginUser.username
userEntity.email = loginUser.email
userEntity.pubkey = loginUser.pubKey
userRepository.save(userEntity).catch(() => {
throw new Error('error by save userEntity')
})
})
if (!userEntity) {
throw new Error('error with cannot happen')
}
const user = new User()
user.id = userEntity.id
user.id = dbUser.id
user.email = email
user.firstName = loginUser.firstName
user.lastName = loginUser.lastName
user.username = loginUser.username
user.description = loginUser.description
user.pubkey = loginUserPubKeyString
user.language = loginUser.language
user.firstName = dbUser.firstName
user.lastName = dbUser.lastName
user.pubkey = dbUser.pubKey.toString('hex')
user.language = dbUser.language
// Elopage Status & Stored PublisherId
user.hasElopage = await this.hasElopage({ pubKey: loginUserPubKeyString })
user.hasElopage = await this.hasElopage({ pubKey: dbUser.pubKey.toString('hex') })
if (!user.hasElopage && publisherId) {
user.publisherId = publisherId
// TODO: Check if we can use updateUserInfos
// await this.updateUserInfos({ publisherId }, { pubKey: loginUser.pubKey })
const loginUserRepository = getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findOneOrFail({ email: userEntity.email })
loginUser.publisherId = publisherId
loginUserRepository.save(loginUser)
dbUser.publisherId = publisherId
DbUser.save(dbUser)
}
// coinAnimation
const userSettingRepository = getCustomRepository(UserSettingRepository)
const coinanimation = await userSettingRepository
.readBoolean(userEntity.id, Setting.COIN_ANIMATION)
.readBoolean(dbUser.id, Setting.COIN_ANIMATION)
.catch((error) => {
throw new Error(error)
})
user.coinanimation = coinanimation
// context.role is not set to the actual role yet on login
const serverUserRepository = await getCustomRepository(ServerUserRepository)
const countServerUsers = await serverUserRepository.count({ email: user.email })
const countServerUsers = await ServerUser.count({ email: user.email })
user.isAdmin = countServerUsers > 0
context.setHeaders.push({
key: 'token',
value: encode(loginUser.pubKey),
value: encode(dbUser.pubKey),
})
return user
@ -371,13 +333,6 @@ export class UserResolver {
language = DEFAULT_LANGUAGE
}
// Validate username
// TODO: never true
const username = ''
if (username.length > 3 && !this.checkUsername({ username })) {
throw new Error('Username already in use')
}
// Validate email unique
// TODO: i can register an email in upper/lower case twice
const userRepository = getCustomRepository(UserRepository)
@ -393,18 +348,18 @@ export class UserResolver {
// const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
const emailHash = getEmailHash(email)
// Table: login_users
const loginUser = new LoginUser()
loginUser.email = email
loginUser.firstName = firstName
loginUser.lastName = lastName
loginUser.username = username
loginUser.description = ''
const dbUser = new DbUser()
dbUser.email = email
dbUser.firstName = firstName
dbUser.lastName = lastName
dbUser.emailHash = emailHash
dbUser.language = language
dbUser.publisherId = publisherId
dbUser.passphrase = passphrase.join(' ')
// TODO this field has no null allowed unlike the loginServer table
// dbUser.pubKey = Buffer.from(randomBytes(32)) // Buffer.alloc(32, 0) default to 0000...
// dbUser.pubkey = keyPair[0]
// loginUser.password = passwordHash[0].readBigUInt64LE() // using the shorthash
loginUser.emailHash = emailHash
loginUser.language = language
loginUser.groupId = 1
loginUser.publisherId = publisherId
// loginUser.pubKey = keyPair[0]
// loginUser.privKey = encryptedPrivkey
@ -412,43 +367,15 @@ export class UserResolver {
await queryRunner.connect()
await queryRunner.startTransaction('READ UNCOMMITTED')
try {
const { id: loginUserId } = await queryRunner.manager.save(loginUser).catch((error) => {
await queryRunner.manager.save(dbUser).catch((error) => {
// eslint-disable-next-line no-console
console.log('insert LoginUser failed', error)
throw new Error('insert user failed')
})
// Table: login_user_backups
const loginUserBackup = new LoginUserBackup()
loginUserBackup.userId = loginUserId
loginUserBackup.passphrase = passphrase.join(' ') // login server saves trailing space
loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER;
await queryRunner.manager.save(loginUserBackup).catch((error) => {
// eslint-disable-next-line no-console
console.log('insert LoginUserBackup failed', error)
throw new Error('insert user backup failed')
})
// Table: state_users
const dbUser = new DbUser()
dbUser.email = email
dbUser.firstName = firstName
dbUser.lastName = lastName
dbUser.username = username
// TODO this field has no null allowed unlike the loginServer table
dbUser.pubkey = Buffer.from(randomBytes(32)) // Buffer.alloc(32, 0) default to 0000...
// dbUser.pubkey = keyPair[0]
await queryRunner.manager.save(dbUser).catch((er) => {
// eslint-disable-next-line no-console
console.log('Error while saving dbUser', er)
console.log('Error while saving dbUser', error)
throw new Error('error saving user')
})
// Store EmailOptIn in DB
// TODO: this has duplicate code with sendResetPasswordEmail
const emailOptIn = await createEmailOptIn(loginUserId, queryRunner)
const emailOptIn = await createEmailOptIn(dbUser.id, queryRunner)
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
/{code}/g,
@ -480,15 +407,14 @@ export class UserResolver {
@Authorized([RIGHTS.SEND_ACTIVATION_EMAIL])
@Mutation(() => Boolean)
async sendActivationEmail(@Arg('email') email: string): Promise<boolean> {
const loginUserRepository = getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findOneOrFail({ email: email })
const user = await DbUser.findOneOrFail({ email: email })
const queryRunner = getConnection().createQueryRunner()
await queryRunner.connect()
await queryRunner.startTransaction('READ UNCOMMITTED')
try {
const emailOptIn = await createEmailOptIn(loginUser.id, queryRunner)
const emailOptIn = await createEmailOptIn(user.id, queryRunner)
const activationLink = CONFIG.EMAIL_LINK_VERIFICATION.replace(
/{code}/g,
@ -497,8 +423,8 @@ export class UserResolver {
const emailSent = await sendAccountActivationEmail({
link: activationLink,
firstName: loginUser.firstName,
lastName: loginUser.lastName,
firstName: user.firstName,
lastName: user.lastName,
email,
})
@ -522,10 +448,9 @@ export class UserResolver {
async sendResetPasswordEmail(@Arg('email') email: string): Promise<boolean> {
// TODO: this has duplicate code with createUser
const loginUserRepository = await getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findOneOrFail({ email })
const user = await DbUser.findOneOrFail({ email })
const optInCode = await getOptInCode(loginUser)
const optInCode = await getOptInCode(user.id)
const link = CONFIG.EMAIL_LINK_SETPASSWORD.replace(
/{code}/g,
@ -534,8 +459,8 @@ export class UserResolver {
const emailSent = await sendResetPasswordEmail({
link,
firstName: loginUser.firstName,
lastName: loginUser.lastName,
firstName: user.firstName,
lastName: user.lastName,
email,
})
@ -575,34 +500,18 @@ export class UserResolver {
throw new Error('Code is older than 10 minutes')
}
// load loginUser
const loginUserRepository = await getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository
.findOneOrFail({ id: optInCode.userId })
.catch(() => {
throw new Error('Could not find corresponding Login User')
})
// load user
const dbUserRepository = await getCustomRepository(UserRepository)
const dbUser = await dbUserRepository.findOneOrFail({ email: loginUser.email }).catch(() => {
throw new Error('Could not find corresponding User')
const user = await DbUser.findOneOrFail({ id: optInCode.userId }).catch(() => {
throw new Error('Could not find corresponding Login User')
})
const loginUserBackupRepository = await getRepository(LoginUserBackup)
let loginUserBackup = await loginUserBackupRepository.findOne({ userId: loginUser.id })
// Generate Passphrase if needed
if (!loginUserBackup) {
if (!user.passphrase) {
const passphrase = PassphraseGenerate()
loginUserBackup = new LoginUserBackup()
loginUserBackup.userId = loginUser.id
loginUserBackup.passphrase = passphrase.join(' ') // login server saves trailing space
loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER;
loginUserBackupRepository.save(loginUserBackup)
user.passphrase = passphrase.join(' ')
}
const passphrase = loginUserBackup.passphrase.split(' ')
const passphrase = user.passphrase.split(' ')
if (passphrase.length < PHRASE_WORD_COUNT) {
// TODO if this can happen we cannot recover from that
// this seem to be good on production data, if we dont
@ -611,29 +520,23 @@ export class UserResolver {
}
// Activate EMail
loginUser.emailChecked = true
user.emailChecked = true
// Update Password
const passwordHash = SecretKeyCryptographyCreateKey(loginUser.email, password) // return short and long hash
const passwordHash = SecretKeyCryptographyCreateKey(user.email, password) // return short and long hash
const keyPair = KeyPairEd25519Create(passphrase) // return pub, priv Key
const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
loginUser.password = passwordHash[0].readBigUInt64LE() // using the shorthash
loginUser.pubKey = keyPair[0]
loginUser.privKey = encryptedPrivkey
dbUser.pubkey = keyPair[0]
user.password = passwordHash[0].readBigUInt64LE() // using the shorthash
user.pubKey = keyPair[0]
user.privKey = encryptedPrivkey
const queryRunner = getConnection().createQueryRunner()
await queryRunner.connect()
await queryRunner.startTransaction('READ UNCOMMITTED')
try {
// Save loginUser
await queryRunner.manager.save(loginUser).catch((error) => {
throw new Error('error saving loginUser: ' + error)
})
// Save user
await queryRunner.manager.save(dbUser).catch((error) => {
await queryRunner.manager.save(user).catch((error) => {
throw new Error('error saving user: ' + error)
})
@ -654,12 +557,7 @@ export class UserResolver {
// TODO do we always signUp the user? How to handle things with old users?
if (optInCode.emailOptInTypeId === EMAIL_OPT_IN_REGISTER) {
try {
await klicktippSignIn(
loginUser.email,
loginUser.language,
loginUser.firstName,
loginUser.lastName,
)
await klicktippSignIn(user.email, user.language, user.firstName, user.lastName)
} catch {
// TODO is this a problem?
// eslint-disable-next-line no-console
@ -677,8 +575,6 @@ export class UserResolver {
{
firstName,
lastName,
description,
username,
language,
publisherId,
password,
@ -689,61 +585,42 @@ export class UserResolver {
): Promise<boolean> {
const userRepository = getCustomRepository(UserRepository)
const userEntity = await userRepository.findByPubkeyHex(context.pubKey)
const loginUserRepository = getCustomRepository(LoginUserRepository)
const loginUser = await loginUserRepository.findOneOrFail({ email: userEntity.email })
if (username) {
throw new Error('change username currently not supported!')
// TODO: this error was thrown on login_server whenever you tried to change the username
// to anything except "" which is an exception to the rules below. Those were defined
// aswell, even tho never used.
// ^[a-zA-Z][a-zA-Z0-9_-]*$
// username must start with [a-z] or [A-Z] and than can contain also [0-9], - and _
// username already used
// userEntity.username = username
}
if (firstName) {
loginUser.firstName = firstName
userEntity.firstName = firstName
}
if (lastName) {
loginUser.lastName = lastName
userEntity.lastName = lastName
}
if (description) {
loginUser.description = description
}
if (language) {
if (!isLanguage(language)) {
throw new Error(`"${language}" isn't a valid language`)
}
loginUser.language = language
userEntity.language = language
}
if (password && passwordNew) {
// TODO: This had some error cases defined - like missing private key. This is no longer checked.
const oldPasswordHash = SecretKeyCryptographyCreateKey(loginUser.email, password)
if (BigInt(loginUser.password.toString()) !== oldPasswordHash[0].readBigUInt64LE()) {
const oldPasswordHash = SecretKeyCryptographyCreateKey(userEntity.email, password)
if (BigInt(userEntity.password.toString()) !== oldPasswordHash[0].readBigUInt64LE()) {
throw new Error(`Old password is invalid`)
}
const privKey = SecretKeyCryptographyDecrypt(loginUser.privKey, oldPasswordHash[1])
const privKey = SecretKeyCryptographyDecrypt(userEntity.privKey, oldPasswordHash[1])
const newPasswordHash = SecretKeyCryptographyCreateKey(loginUser.email, passwordNew) // return short and long hash
const newPasswordHash = SecretKeyCryptographyCreateKey(userEntity.email, passwordNew) // return short and long hash
const encryptedPrivkey = SecretKeyCryptographyEncrypt(privKey, newPasswordHash[1])
// Save new password hash and newly encrypted private key
loginUser.password = newPasswordHash[0].readBigUInt64LE()
loginUser.privKey = encryptedPrivkey
userEntity.password = newPasswordHash[0].readBigUInt64LE()
userEntity.privKey = encryptedPrivkey
}
// Save publisherId only if Elopage is not yet registered
if (publisherId && !(await this.hasElopage(context))) {
loginUser.publisherId = publisherId
userEntity.publisherId = publisherId
}
const queryRunner = getConnection().createQueryRunner()
@ -760,10 +637,6 @@ export class UserResolver {
})
}
await queryRunner.manager.save(loginUser).catch((error) => {
throw new Error('error saving loginUser: ' + error)
})
await queryRunner.manager.save(userEntity).catch((error) => {
throw new Error('error saving user: ' + error)
})
@ -779,30 +652,6 @@ export class UserResolver {
return true
}
@Authorized([RIGHTS.CHECK_USERNAME])
@Query(() => Boolean)
async checkUsername(@Args() { username }: CheckUsernameArgs): Promise<boolean> {
// Username empty?
if (username === '') {
throw new Error('Username must be set.')
}
// Do we fullfil the minimum character length?
const MIN_CHARACTERS_USERNAME = 2
if (username.length < MIN_CHARACTERS_USERNAME) {
throw new Error(`Username must be at minimum ${MIN_CHARACTERS_USERNAME} characters long.`)
}
const usersFound = await LoginUser.count({ username })
// Username already present?
if (usersFound !== 0) {
throw new Error(`Username "${username}" already taken.`)
}
return true
}
@Authorized([RIGHTS.HAS_ELOPAGE])
@Query(() => Boolean)
async hasElopage(@Ctx() context: any): Promise<boolean> {
@ -812,8 +661,6 @@ export class UserResolver {
return false
}
const loginElopageBuysRepository = getCustomRepository(LoginElopageBuysRepository)
const elopageBuyCount = await loginElopageBuysRepository.count({ payerEmail: userEntity.email })
return elopageBuyCount > 0
return hasElopageBuys(userEntity.email)
}
}

View File

@ -4,7 +4,7 @@ export const accountActivation = {
text: (data: { link: string; firstName: string; lastName: string; email: string }): string =>
`Hallo ${data.firstName} ${data.lastName},
Deine EMail wurde soeben bei Gradido registriert.
Deine E-Mail-Adresse wurde soeben bei Gradido registriert.
Klicke bitte auf diesen Link, um die Registrierung abzuschließen und dein Gradido-Konto zu aktivieren:
${data.link}

View File

@ -1,7 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ApolloLogPlugin } from 'apollo-log'
import { ApolloLogPlugin, LogMutateData } from 'apollo-log'
import cloneDeep from 'lodash.clonedeep'
const plugins = [
{
@ -21,7 +22,22 @@ const plugins = [
}
},
},
ApolloLogPlugin(),
ApolloLogPlugin({
mutate: (data: LogMutateData) => {
// We need to deep clone the object in order to not modify the actual request
const dataCopy = cloneDeep(data)
// mask password if part of the query
if (dataCopy.context.request.variables && dataCopy.context.request.variables.password) {
dataCopy.context.request.variables.password = '***'
}
// mask token at all times
dataCopy.context.context.token = '***'
return dataCopy
},
}),
]
export default plugins

View File

@ -1,5 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { LoginElopageBuys } from '@entity/LoginElopageBuys'
@EntityRepository(LoginElopageBuys)
export class LoginElopageBuysRepository extends Repository<LoginElopageBuys> {}

View File

@ -1,5 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
@EntityRepository(LoginEmailOptIn)
export class LoginEmailOptInRepository extends Repository<LoginEmailOptIn> {}

View File

@ -1,24 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { LoginUser } from '@entity/LoginUser'
@EntityRepository(LoginUser)
export class LoginUserRepository extends Repository<LoginUser> {
async findByEmail(email: string): Promise<LoginUser> {
return this.createQueryBuilder('loginUser')
.where('loginUser.email = :email', { email })
.getOneOrFail()
}
async findBySearchCriteria(searchCriteria: string): Promise<LoginUser[]> {
return await this.createQueryBuilder('user')
.where(
'user.firstName like :name or user.lastName like :lastName or user.email like :email',
{
name: `%${searchCriteria}%`,
lastName: `%${searchCriteria}%`,
email: `%${searchCriteria}%`,
},
)
.getMany()
}
}

View File

@ -1,5 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { LoginUserBackup } from '@entity/LoginUserBackup'
@EntityRepository(LoginUserBackup)
export class LoginUserBackupRepository extends Repository<LoginUserBackup> {}

View File

@ -1,5 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { ServerUser } from '@entity/ServerUser'
@EntityRepository(ServerUser)
export class ServerUserRepository extends Repository<ServerUser> {}

View File

@ -1,5 +0,0 @@
import { EntityRepository, Repository } from '@dbTools/typeorm'
import { TransactionCreation } from '@entity/TransactionCreation'
@EntityRepository(TransactionCreation)
export class TransactionCreationRepository extends Repository<TransactionCreation> {}

View File

@ -5,7 +5,7 @@ import { User } from '@entity/User'
export class UserRepository extends Repository<User> {
async findByPubkeyHex(pubkeyHex: string): Promise<User> {
return this.createQueryBuilder('user')
.where('hex(user.pubkey) = :pubkeyHex', { pubkeyHex })
.where('hex(user.pubKey) = :pubkeyHex', { pubkeyHex })
.getOneOrFail()
}

View File

@ -0,0 +1,6 @@
import { LoginElopageBuys } from '@entity/LoginElopageBuys'
export async function hasElopageBuys(email: string): Promise<boolean> {
const elopageBuyCount = await LoginElopageBuys.count({ payerEmail: email })
return elopageBuyCount > 0
}

View File

@ -28,16 +28,13 @@
*/
import { LoginElopageBuys } from '@entity/LoginElopageBuys'
import { getCustomRepository } from '@dbTools/typeorm'
import { UserResolver } from '../graphql/resolver/UserResolver'
import { LoginElopageBuysRepository } from '../typeorm/repository/LoginElopageBuys'
import { LoginUserRepository } from '../typeorm/repository/LoginUser'
import { User as dbUser } from '@entity/User'
export const elopageWebhook = async (req: any, res: any): Promise<void> => {
// eslint-disable-next-line no-console
console.log('Elopage Hook received', req.body)
res.status(200).end() // Responding is important
const loginElopageBuyRepository = await getCustomRepository(LoginElopageBuysRepository)
const loginElopageBuy = new LoginElopageBuys()
const {
@ -56,12 +53,26 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
membership,
} = req.body
loginElopageBuy.affiliateProgramId = parseInt(product.affiliate_program_id)
loginElopageBuy.publisherId = parseInt(publisher.id)
loginElopageBuy.orderId = parseInt(order_id)
loginElopageBuy.productId = parseInt(product_id)
// Do not process certain events
if (['lesson.viewed', 'lesson.completed', 'lesson.commented'].includes(event)) {
// eslint-disable-next-line no-console
console.log('User viewed, completed or commented - not saving hook')
return
}
if (!product || !publisher || !membership || !payer) {
// eslint-disable-next-line no-console
console.log('Elopage Hook: Not an event we can process')
return
}
loginElopageBuy.affiliateProgramId = parseInt(product.affiliate_program_id) || null
loginElopageBuy.publisherId = parseInt(publisher.id) || null
loginElopageBuy.orderId = parseInt(order_id) || null
loginElopageBuy.productId = parseInt(product_id) || null
// TODO: WHAT THE ACTUAL FUK? Please save this as float in the future directly in the database
loginElopageBuy.productPrice = Math.trunc(parseFloat(product.price) * 100)
const productPrice = parseFloat(product.price)
loginElopageBuy.productPrice = productPrice ? Math.trunc(productPrice * 100) : 0
loginElopageBuy.payerEmail = payer.email
loginElopageBuy.publisherEmail = publisher.email
// eslint-disable-next-line camelcase
@ -69,21 +80,20 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
loginElopageBuy.successDate = new Date(success_date)
loginElopageBuy.event = event
// TODO this was never set on login_server - its unclear if this is the correct value
loginElopageBuy.elopageUserId = parseInt(membership.id)
loginElopageBuy.elopageUserId = parseInt(membership.id) || null
const firstName = payer.first_name
const lastName = payer.last_name
// Do not process certain events
if (['lesson.viewed', 'lesson.completed', 'lesson.commented'].includes(loginElopageBuy.event)) {
// Save the hook data
try {
await LoginElopageBuys.save(loginElopageBuy)
} catch (error) {
// eslint-disable-next-line no-console
console.log('User viewed, completed or commented - not saving hook')
console.log('Error saving LoginElopageBuy', error)
return
}
// Save the hook data
await loginElopageBuyRepository.save(loginElopageBuy)
// create user for certain products
/*
Registrierung - Schritt 1 von 3, 36001
@ -93,7 +103,10 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
Business-Mitgliedschaft, 43960
Förderbeitrag: 49106
*/
if ([36001, 43741, 43870, 43944, 43960, 49106].includes(loginElopageBuy.productId)) {
if (
loginElopageBuy.productId &&
[36001, 43741, 43870, 43944, 43960, 49106].includes(loginElopageBuy.productId)
) {
const email = loginElopageBuy.payerEmail
const VALIDATE_EMAIL = /^[a-zA-Z0-9.!#$%&?*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
@ -114,8 +127,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
}
// Do we already have such a user?
const loginUserRepository = await getCustomRepository(LoginUserRepository)
if ((await loginUserRepository.count({ email })) !== 0) {
if ((await dbUser.count({ email })) !== 0) {
// eslint-disable-next-line no-console
console.log(`Did not create User - already exists with email: ${email}`)
return
@ -127,7 +139,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
email,
firstName,
lastName,
publisherId: loginElopageBuy.publisherId,
publisherId: loginElopageBuy.publisherId || 0, // This seemed to be the default value if not set
})
} catch (error) {
// eslint-disable-next-line no-console

View File

@ -913,6 +913,18 @@
"@types/koa-compose" "*"
"@types/node" "*"
"@types/lodash.clonedeep@^4.5.6":
version "4.5.6"
resolved "https://registry.yarnpkg.com/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.6.tgz#3b6c40a0affe0799a2ce823b440a6cf33571d32b"
integrity sha512-cE1jYr2dEg1wBImvXlNtp0xDoS79rfEdGozQVgliDZj1uERH4k+rmEMTudP9b4VQ8O6nRb5gPqft0QzEQGMQgA==
dependencies:
"@types/lodash" "*"
"@types/lodash@*":
version "4.14.178"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"
integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==
"@types/long@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9"

View File

@ -1,10 +0,0 @@
config/app.php
logs/
src/GPBMetadata/
tmp/
vendor/
websrc/node_modules/
websrc/package-lock.json
mithril_client/
websrc/src/less-files.css

View File

@ -1,3 +0,0 @@
[submodule "src/protobuf"]
path = src/protobuf
url = git@github.com:gradido/gradido_protocol.git

View File

@ -1,30 +0,0 @@
FROM phpdockerio/php74-fpm as community_server
# install php fpm
RUN apt-get update \
&& apt-get -y --no-install-recommends install curl unzip php7.4-curl php7.4-fpm php7.4-mbstring php7.4-intl php7.4-xml php7.4-pdo php7.4-mysql php7.4-xdebug \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
WORKDIR /var/www/cakephp
RUN mkdir logs && mkdir tmp && chmod 777 logs && chmod 777 tmp
COPY ./community_server/ .
COPY ./configs/community_server/app.php ./config/
RUN composer update
RUN composer dump-autoload
######### special for code coverage and testing
FROM community_server as test
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/*
ENV XDEBUG_MODE=coverage
#RUN composer require --dev rregeer/phpunit-coverage-check
#CMD ./vendor/bin/phpunit --coverage-clover=./webroot/coverage/clover.xml
CMD ./vendor/bin/phpunit --coverage-text=./webroot/coverage/coverage.info

View File

@ -1,51 +0,0 @@
# CakePHP Application Skeleton
[![Build Status](https://img.shields.io/travis/cakephp/app/master.svg?style=flat-square)](https://travis-ci.org/cakephp/app)
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/app.svg?style=flat-square)](https://packagist.org/packages/cakephp/app)
A skeleton for creating applications with [CakePHP](https://cakephp.org) 3.x.
The framework source code can be found here: [cakephp/cakephp](https://github.com/cakephp/cakephp).
## Installation
1. Download [Composer](https://getcomposer.org/doc/00-intro.md) or update `composer self-update`.
2. Run `php composer.phar create-project --prefer-dist cakephp/app [app_name]`.
If Composer is installed globally, run
```bash
composer create-project --prefer-dist cakephp/app
```
In case you want to use a custom app dir name (e.g. `/myapp/`):
```bash
composer create-project --prefer-dist cakephp/app myapp
```
You can now either use your machine's webserver to view the default home page, or start
up the built-in webserver with:
```bash
bin/cake server -p 8765
```
Then visit `http://localhost:8765` to see the welcome page.
## Update
Since this skeleton is a starting point for your application and various files
would have been modified as per your needs, there isn't a way to provide
automated upgrades, so you have to do any updates manually.
## Configuration
Read and edit `config/app.php` and setup the `'Datasources'` and any other
configuration relevant for your application.
## Layout
The app skeleton uses a subset of [Foundation](http://foundation.zurb.com/) (v5) CSS
framework by default. You can, however, replace it with any other library or
custom styles.

View File

@ -1,75 +0,0 @@
#!/usr/bin/env sh
################################################################################
#
# Cake is a shell script for invoking CakePHP shell commands
#
# CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
#
# Licensed under The MIT License
# For full copyright and license information, please see the LICENSE.txt
# Redistributions of files must retain the above copyright notice.
#
# @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
# @link https://cakephp.org CakePHP(tm) Project
# @since 1.2.0
# @license https://opensource.org/licenses/mit-license.php MIT License
#
################################################################################
# Canonicalize by following every symlink of the given name recursively
canonicalize() {
NAME="$1"
if [ -f "$NAME" ]
then
DIR=$(dirname -- "$NAME")
NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
fi
while [ -h "$NAME" ]; do
DIR=$(dirname -- "$NAME")
SYM=$(readlink "$NAME")
NAME=$(cd "$DIR" > /dev/null && cd "$(dirname -- "$SYM")" > /dev/null && pwd)/$(basename -- "$SYM")
done
echo "$NAME"
}
# Find a CLI version of PHP
findCliPhp() {
for TESTEXEC in php php-cli /usr/local/bin/php
do
SAPI=$(echo "<?= PHP_SAPI ?>" | $TESTEXEC 2>/dev/null)
if [ "$SAPI" = "cli" ]
then
echo $TESTEXEC
return
fi
done
echo "Failed to find a CLI version of PHP; falling back to system standard php executable" >&2
echo "php";
}
# If current path is a symlink, resolve to real path
realname="$0"
if [ -L "$realname" ]
then
realname=$(readlink -f "$0")
fi
CONSOLE=$(dirname -- "$(canonicalize "$realname")")
APP=$(dirname "$CONSOLE")
# If your CLI PHP is somewhere that this doesn't find, you can define a PHP environment
# variable with the correct path in it.
if [ -z "$PHP" ]
then
PHP=$(findCliPhp)
fi
if [ "$(basename "$realname")" != 'cake' ]
then
exec "$PHP" "$CONSOLE"/cake.php "$(basename "$realname")" "$@"
else
exec "$PHP" "$CONSOLE"/cake.php "$@"
fi
exit

View File

@ -1,27 +0,0 @@
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Cake is a Windows batch script for invoking CakePHP shell commands
::
:: CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
:: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
::
:: Licensed under The MIT License
:: Redistributions of files must retain the above copyright notice.
::
:: @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
:: @link https://cakephp.org CakePHP(tm) Project
:: @since 2.0.0
:: @license https://opensource.org/licenses/mit-license.php MIT License
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
SET app=%0
SET lib=%~dp0
php "%lib%cake.php" %*
echo.
exit /B %ERRORLEVEL%

View File

@ -1,12 +0,0 @@
#!/usr/bin/php -q
<?php
// Check platform requirements
require dirname(__DIR__) . '/config/requirements.php';
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Application;
use Cake\Console\CommandRunner;
// Build the runner with an application and root executable name.
$runner = new CommandRunner(new Application(dirname(__DIR__) . '/config'), 'cake');
exit($runner->run($argv));

View File

@ -1,58 +0,0 @@
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "https://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=5.6",
"cakephp/cakephp": "3.9.*",
"cakephp/plugin-installer": "^1.0",
"datto/json-rpc": "^6.0",
"google/protobuf": "v3.10.*",
"mobiledetect/mobiledetectlib": "2.*",
"paragonie/sodium_compat": "^1.11",
"tuupola/base58": "^2.0"
},
"require-dev": {
"cakephp/bake": "^1.9.0",
"cakephp/cakephp-codesniffer": "^3.0",
"cakephp/debug_kit": "^3.17.0",
"josegonzalez/dotenv": "3.*",
"phpunit/phpunit": "^5.7|^6.0",
"psy/psysh": "@stable"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
"dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility."
},
"autoload": {
"psr-4": {
"App\\": "src/",
"" : "src/",
"GPBMetadata\\Gradido\\": "src/Model/Messages/GPBMetadata/Gradido/",
"Proto\\Gradido\\" : "src/Model/Messages/Proto/Gradido/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-create-project-cmd": "App\\Console\\Installer::postInstall",
"check": [
"@test",
"@cs-check"
],
"cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"test": "phpunit --colors=always"
},
"prefer-stable": true,
"config": {
"sort-packages": true
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,407 +0,0 @@
<?php
use Cake\Cache\Engine\FileEngine;
use Cake\Database\Connection;
use Cake\Database\Driver\Mysql;
use Cake\Error\ExceptionRenderer;
use Cake\Log\Engine\FileLog;
use Cake\Mailer\Transport\MailTransport;
return [
/**
* Debug Level:
*
* Production Mode:
* false: No error messages, errors, or warnings shown.
*
* Development Mode:
* true: Errors and warnings shown.
*/
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
/**
* Configure basic information about the application.
*
* - namespace - The namespace to find app classes under.
* - defaultLocale - The default locale for translation, formatting currencies and numbers, date and time.
* - encoding - The encoding used for HTML + database connections.
* - base - The base directory the app resides in. If false this
* will be auto detected.
* - dir - Name of app directory.
* - webroot - The webroot directory.
* - wwwRoot - The file path to webroot.
* - baseUrl - To configure CakePHP to *not* use mod_rewrite and to
* use CakePHP pretty URLs, remove these .htaccess
* files:
* /.htaccess
* /webroot/.htaccess
* And uncomment the baseUrl key below.
* - fullBaseUrl - A base URL to use for absolute links. When set to false (default)
* CakePHP generates required value based on `HTTP_HOST` environment variable.
* However, you can define it manually to optimize performance or if you
* are concerned about people manipulating the `Host` header.
* - imageBaseUrl - Web path to the public images directory under webroot.
* - cssBaseUrl - Web path to the public css directory under webroot.
* - jsBaseUrl - Web path to the public js directory under webroot.
* - paths - Configure paths for non class based resources. Supports the
* `plugins`, `templates`, `locales` subkeys, which allow the definition of
* paths for plugins, view templates and locale files respectively.
*/
'App' => [
'namespace' => 'App',
'encoding' => env('APP_ENCODING', 'UTF-8'),
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),
'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'),
'base' => false,
'dir' => 'src',
'webroot' => 'webroot',
'wwwRoot' => WWW_ROOT,
//'baseUrl' => env('SCRIPT_NAME'),
'fullBaseUrl' => false,
'imageBaseUrl' => 'img/',
'cssBaseUrl' => 'css/',
'jsBaseUrl' => 'js/',
'paths' => [
'plugins' => [ROOT . DS . 'plugins' . DS],
'templates' => [APP . 'Template' . DS],
'locales' => [APP . 'Locale' . DS],
],
],
/**
* Security and encryption configuration
*
* - salt - A random string used in security hashing methods.
* The salt value is also used as the encryption key.
* You should treat it as extremely sensitive data.
*/
'Security' => [
'salt' => env('SECURITY_SALT', '__SALT__'),
],
/**
* Apply timestamps with the last modified time to static assets (js, css, images).
* Will append a querystring parameter containing the time the file was modified.
* This is useful for busting browser caches.
*
* Set to true to apply timestamps when debug is true. Set to 'force' to always
* enable timestamping regardless of debug value.
*/
'Asset' => [
//'timestamp' => true,
// 'cacheTime' => '+1 year'
],
/**
* Configure the cache adapters.
*/
'Cache' => [
'default' => [
'className' => FileEngine::class,
'path' => CACHE,
'url' => env('CACHE_DEFAULT_URL', null),
],
/**
* Configure the cache used for general framework caching.
* Translation cache files are stored with this configuration.
* Duration will be set to '+2 minutes' in bootstrap.php when debug = true
* If you set 'className' => 'Null' core cache will be disabled.
*/
'_cake_core_' => [
'className' => FileEngine::class,
'prefix' => 'myapp_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+1 years',
'url' => env('CACHE_CAKECORE_URL', null),
],
/**
* Configure the cache for model and datasource caches. This cache
* configuration is used to store schema descriptions, and table listings
* in connections.
* Duration will be set to '+2 minutes' in bootstrap.php when debug = true
*/
'_cake_model_' => [
'className' => FileEngine::class,
'prefix' => 'myapp_cake_model_',
'path' => CACHE . 'models/',
'serialize' => true,
'duration' => '+1 years',
'url' => env('CACHE_CAKEMODEL_URL', null),
],
/**
* Configure the cache for routes. The cached routes collection is built the
* first time the routes are processed via `config/routes.php`.
* Duration will be set to '+2 seconds' in bootstrap.php when debug = true
*/
'_cake_routes_' => [
'className' => FileEngine::class,
'prefix' => 'myapp_cake_routes_',
'path' => CACHE,
'serialize' => true,
'duration' => '+1 years',
'url' => env('CACHE_CAKEROUTES_URL', null),
],
],
/**
* Configure the Error and Exception handlers used by your application.
*
* By default errors are displayed using Debugger, when debug is true and logged
* by Cake\Log\Log when debug is false.
*
* In CLI environments exceptions will be printed to stderr with a backtrace.
* In web environments an HTML page will be displayed for the exception.
* With debug true, framework errors like Missing Controller will be displayed.
* When debug is false, framework errors will be coerced into generic HTTP errors.
*
* Options:
*
* - `errorLevel` - int - The level of errors you are interested in capturing.
* - `trace` - boolean - Whether or not backtraces should be included in
* logged errors/exceptions.
* - `log` - boolean - Whether or not you want exceptions logged.
* - `exceptionRenderer` - string - The class responsible for rendering
* uncaught exceptions. If you choose a custom class you should place
* the file for that class in src/Error. This class needs to implement a
* render method.
* - `skipLog` - array - List of exceptions to skip for logging. Exceptions that
* extend one of the listed exceptions will also be skipped for logging.
* E.g.:
* `'skipLog' => ['Cake\Http\Exception\NotFoundException', 'Cake\Http\Exception\UnauthorizedException']`
* - `extraFatalErrorMemory` - int - The number of megabytes to increase
* the memory limit by when a fatal error is encountered. This allows
* breathing room to complete logging or error handling.
*/
'Error' => [
'errorLevel' => E_ALL,
'exceptionRenderer' => ExceptionRenderer::class,
'skipLog' => [],
'log' => true,
'trace' => true,
],
/**
* Email configuration.
*
* By defining transports separately from delivery profiles you can easily
* re-use transport configuration across multiple profiles.
*
* You can specify multiple configurations for production, development and
* testing.
*
* Each transport needs a `className`. Valid options are as follows:
*
* Mail - Send using PHP mail function
* Smtp - Send using SMTP
* Debug - Do not send the email, just return the result
*
* You can add custom transports (or override existing transports) by adding the
* appropriate file to src/Mailer/Transport. Transports should be named
* 'YourTransport.php', where 'Your' is the name of the transport.
*/
'EmailTransport' => [
'default' => [
'className' => MailTransport::class,
/*
* The following keys are used in SMTP transports:
*/
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => null,
'password' => null,
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
/**
* Email delivery profiles
*
* Delivery profiles allow you to predefine various properties about email
* messages from your application and give the settings a name. This saves
* duplication across your application and makes maintenance and development
* easier. Each profile accepts a number of keys. See `Cake\Mailer\Email`
* for more information.
*/
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'you@localhost',
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
],
/**
* Connection information used by the ORM to connect
* to your application's datastores.
*
* ### Notes
* - Drivers include Mysql Postgres Sqlite Sqlserver
* See vendor\cakephp\cakephp\src\Database\Driver for complete list
* - Do not use periods in database name - it may lead to error.
* See https://github.com/cakephp/cakephp/issues/6471 for details.
* - 'encoding' is recommended to be set to full UTF-8 4-Byte support.
* E.g set it to 'utf8mb4' in MariaDB and MySQL and 'utf8' for any
* other RDBMS.
*/
'Datasources' => [
'default' => [
'className' => Connection::class,
'driver' => Mysql::class,
'persistent' => false,
'host' => 'localhost',
/*
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'my_app',
'password' => 'secret',
'database' => 'my_app',
/*
* You do not need to set this flag to use full utf-8 encoding (internal default since CakePHP 3.6).
*/
//'encoding' => 'utf8mb4',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
/**
* Set identifier quoting to true if you are using reserved words or
* special characters in your table or column names. Enabling this
* setting will result in queries built using the Query Builder having
* identifiers quoted when creating SQL. It should be noted that this
* decreases performance because each query needs to be traversed and
* manipulated before being executed.
*/
'quoteIdentifiers' => false,
/**
* During development, if using MySQL < 5.6, uncommenting the
* following line could boost the speed at which schema metadata is
* fetched from the database. It can also be set directly with the
* mysql configuration directive 'innodb_stats_on_metadata = 0'
* which is the recommended value in production environments
*/
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
'url' => env('DATABASE_URL', null),
],
/**
* The test connection is used during the test suite.
*/
'test' => [
'className' => Connection::class,
'driver' => Mysql::class,
'persistent' => false,
'host' => 'localhost',
//'port' => 'non_standard_port_number',
'username' => 'my_app',
'password' => 'secret',
'database' => 'test_myapp',
//'encoding' => 'utf8mb4',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
'log' => false,
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
'url' => env('DATABASE_TEST_URL', null),
],
],
/**
* Configures logging options
*/
'Log' => [
'debug' => [
'className' => FileLog::class,
'path' => LOGS,
'file' => 'debug',
'url' => env('LOG_DEBUG_URL', null),
'scopes' => false,
'levels' => ['notice', 'info', 'debug'],
],
'error' => [
'className' => FileLog::class,
'path' => LOGS,
'file' => 'error',
'url' => env('LOG_ERROR_URL', null),
'scopes' => false,
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
],
// To enable this dedicated query log, you need set your datasource's log flag to true
'queries' => [
'className' => FileLog::class,
'path' => LOGS,
'file' => 'queries',
'url' => env('LOG_QUERIES_URL', null),
'scopes' => ['queriesLog'],
],
],
/**
* Session configuration.
*
* Contains an array of settings to use for session configuration. The
* `defaults` key is used to define a default preset to use for sessions, any
* settings declared here will override the settings of the default config.
*
* ## Options
*
* - `cookie` - The name of the cookie to use. Defaults to 'CAKEPHP'. Avoid using `.` in cookie names,
* as PHP will drop sessions from cookies with `.` in the name.
* - `cookiePath` - The url path for which session cookie is set. Maps to the
* `session.cookie_path` php.ini config. Defaults to base path of app.
* - `timeout` - The time in minutes the session should be valid for.
* Pass 0 to disable checking timeout.
* Please note that php.ini's session.gc_maxlifetime must be equal to or greater
* than the largest Session['timeout'] in all served websites for it to have the
* desired effect.
* - `defaults` - The default configuration set to use as a basis for your session.
* There are four built-in options: php, cake, cache, database.
* - `handler` - Can be used to enable a custom session handler. Expects an
* array with at least the `engine` key, being the name of the Session engine
* class to use for managing the session. CakePHP bundles the `CacheSession`
* and `DatabaseSession` engines.
* - `ini` - An associative array of additional ini values to set.
*
* The built-in `defaults` options are:
*
* - 'php' - Uses settings defined in your php.ini.
* - 'cake' - Saves session files in CakePHP's /tmp directory.
* - 'database' - Uses CakePHP's database sessions.
* - 'cache' - Use the Cache class to save sessions.
*
* To define a custom session handler, save it at src/Network/Session/<name>.php.
* Make sure the class implements PHP's `SessionHandlerInterface` and set
* Session.handler to <name>
*
* To use database sessions, load the SQL file located at config/schema/sessions.sql
*/
'Session' => [
'defaults' => 'php',
],
// Gradido specific configuration
// Login Server ip and port
'LoginServer' => [
'host' => 'http://127.0.0.1',
'port' => 1201
],
'API' => [
'allowedCaller' => [''] // insert domains or ips from login-server and gdt if they not at localhost
],
'ServerAdminEmail' => 'info@gradido.net', // email 'from' field for transfer notification emails
'noReplyEmail' => 'no-replay@gradido.net', // email sender for creation notification emails to user
'GroupNode' => false
];

View File

@ -1,212 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.10.8
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
/*
* Configure paths required to find CakePHP + general filepath constants
*/
require __DIR__ . '/paths.php';
/*
* Bootstrap CakePHP.
*
* Does the various bits of setup that CakePHP needs to do.
* This includes:
*
* - Registering the CakePHP autoloader.
* - Setting the default application paths.
*/
require CORE_PATH . 'config' . DS . 'bootstrap.php';
use Cake\Cache\Cache;
use Cake\Console\ConsoleErrorHandler;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\Plugin;
use Cake\Database\Type;
use Cake\Datasource\ConnectionManager;
use Cake\Error\ErrorHandler;
use Cake\Http\ServerRequest;
use Cake\Log\Log;
use Cake\Mailer\Email;
use Cake\Mailer\TransportFactory;
use Cake\Utility\Inflector;
use Cake\Utility\Security;
/**
* Uncomment block of code below if you want to use `.env` file during development.
* You should copy `config/.env.default to `config/.env` and set/modify the
* variables as required.
*
* It is HIGHLY discouraged to use a .env file in production, due to security risks
* and decreased performance on each request. The purpose of the .env file is to emulate
* the presence of the environment variables like they would be present in production.
*/
// if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
// $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
// $dotenv->parse()
// ->putenv()
// ->toEnv()
// ->toServer();
// }
/*
* Read configuration file and inject configuration into various
* CakePHP classes.
*
* By default there is only one configuration file. It is often a good
* idea to create multiple configuration files, and separate the configuration
* that changes from configuration that does not. This makes deployment simpler.
*/
try {
Configure::config('default', new PhpConfig());
Configure::load('app', 'default', false);
} catch (\Exception $e) {
exit($e->getMessage() . "\n");
}
/*
* Load an environment local configuration file.
* You can use a file like app_local.php to provide local overrides to your
* shared configuration.
*/
//Configure::load('app_local', 'default');
/*
* When debug = true the metadata cache should only last
* for a short time.
*/
if (Configure::read('debug')) {
Configure::write('Cache._cake_model_.duration', '+2 minutes');
Configure::write('Cache._cake_core_.duration', '+2 minutes');
// disable router cache during development
Configure::write('Cache._cake_routes_.duration', '+2 seconds');
}
/*
* Set the default server timezone. Using UTC makes time calculations / conversions easier.
* Check http://php.net/manual/en/timezones.php for list of valid timezone strings.
*/
date_default_timezone_set(Configure::read('App.defaultTimezone'));
/*
* Configure the mbstring extension to use the correct encoding.
*/
mb_internal_encoding(Configure::read('App.encoding'));
/*
* Set the default locale. This controls how dates, number and currency is
* formatted and sets the default language to use for translations.
*/
ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
/*
* Register application error and exception handlers.
*/
$isCli = PHP_SAPI === 'cli';
if ($isCli) {
(new ConsoleErrorHandler(Configure::read('Error')))->register();
} else {
(new ErrorHandler(Configure::read('Error')))->register();
}
/*
* Include the CLI bootstrap overrides.
*/
if ($isCli) {
require __DIR__ . '/bootstrap_cli.php';
}
/*
* Set the full base URL.
* This URL is used as the base of all absolute links.
*
* If you define fullBaseUrl in your config file you can remove this.
*/
if (!Configure::read('App.fullBaseUrl')) {
$s = null;
if (env('HTTPS')) {
$s = 's';
}
$httpHost = env('HTTP_HOST');
if (isset($httpHost)) {
Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
}
unset($httpHost, $s);
}
Cache::setConfig(Configure::consume('Cache'));
ConnectionManager::setConfig(Configure::consume('Datasources'));
TransportFactory::setConfig(Configure::consume('EmailTransport'));
Email::setConfig(Configure::consume('Email'));
Log::setConfig(Configure::consume('Log'));
Security::setSalt(Configure::consume('Security.salt'));
/*
* The default crypto extension in 3.0 is OpenSSL.
* If you are migrating from 2.x uncomment this code to
* use a more compatible Mcrypt based implementation
*/
//Security::engine(new \Cake\Utility\Crypto\Mcrypt());
/*
* Setup detectors for mobile and tablet.
*/
ServerRequest::addDetector('mobile', function ($request) {
$detector = new \Detection\MobileDetect();
return $detector->isMobile();
});
ServerRequest::addDetector('tablet', function ($request) {
$detector = new \Detection\MobileDetect();
return $detector->isTablet();
});
/*
* Enable immutable time objects in the ORM.
*
* You can enable default locale format parsing by adding calls
* to `useLocaleParser()`. This enables the automatic conversion of
* locale specific date formats. For details see
* @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
*/
Type::build('time')
->useImmutable();
Type::build('date')
->useImmutable();
Type::build('datetime')
->useImmutable();
Type::build('timestamp')
->useImmutable();
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, PUT, PATCH, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: *');
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
exit(0);
}
/*
* Custom Inflector rules, can be set to correctly pluralize or singularize
* table, model, controller names or whatever other string is passed to the
* inflection functions.
*/
//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
//Inflector::rules('irregular', ['red' => 'redlings']);
//Inflector::rules('uninflected', ['dontinflectme']);
//Inflector::rules('transliteration', ['/å/' => 'aa']);

View File

@ -1,28 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Configure;
/**
* Additional bootstrapping and configuration for CLI environments should
* be put here.
*/
// Set the fullBaseUrl to allow URLs to be generated in shell tasks.
// This is useful when sending email from shells.
//Configure::write('App.fullBaseUrl', php_uname('n'));
// Set logs to different files so they don't have permission conflicts.
Configure::write('Log.debug.file', 'cli-debug');
Configure::write('Log.error.file', 'cli-error');

View File

@ -1,46 +0,0 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
return [
// Container element used by control().
'inputContainer' => '{{content}}',
// Container element used by control() when a field has an error.
'inputContainerError' => '<div class="{{type}}{{required}} is-invalid">{{content}}{{error}}</div>',
// Label element when inputs are not nested inside the label.
'label' => '<label{{attrs}} class="form-label">{{text}}</label>',
// Generic input element.
'input' => '<input type="{{type}}" class="form-control" name="{{name}}"{{attrs}}/>',
// Textarea input element,
'textarea' => '<textarea class="form-control" name="{{name}}"{{attrs}}>{{value}}</textarea>',
// Error message wrapper elements.
'error' => '<div class="invalid-feedback">'
. '{{content}}'
. '</div>',
// Container for error items.
'errorList' => '{{content}}',
// Error item wrapper.
'errorItem' => '<div>{{text}}</div>'
];
/*
<div class="form-group row showcase_row_area">
<div class="col-md-3 showcase_text_area">
<label for="inputAmount">Betrag in GDD</label>
</div>
<div class="col-md-9 showcase_content_area">
<input type="number" step="0.01" class="form-control" id="inputAmount" name="inputAmount" >
</div>
</div>
<div class="input number required">
<label for="amount">Amount</label>
<input type="number" name="amount" required="required" step="0.01" id="amount">
</div>
*/

View File

@ -1,25 +0,0 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@ -1,88 +0,0 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@ -1,86 +0,0 @@
server {
listen 80 ;
listen [::]:80;
server_name 0.0.0.0;
#include /etc/nginx/common/protect.conf;
#include /etc/nginx/common/protect_add_header.conf;
#include /etc/nginx/common/ssl.conf;
root /usr/share/nginx/html/webroot;
index index.php;
location ~* \.(png|jpg|ico|webp)\$ {
expires 30d;
}
location ~* \.(js|css) {
# expires 1d;
expires 1d;
}
location ~ \.php\$ {
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
#fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
location /account {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$host;
rewrite /account/(.*) /\$1 break;
#proxy_next_upstream error timeout invalid_header http_502 non_idempotent;
proxy_pass http://login-server:1200;
proxy_redirect off;
}
location /login_api {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$host;
rewrite /login_api/(.*) /\$1 break;
proxy_pass http://login-server:1201;
proxy_redirect off;
}
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
# access_log /var/log/nginx/access.log main;
}

View File

@ -1,89 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license MIT License (https://opensource.org/licenses/mit-license.php)
*/
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
* When using custom settings be sure to use the DS and do not add a trailing DS.
*/
/**
* The full path to the directory which holds "src", WITHOUT a trailing DS.
*/
define('ROOT', dirname(__DIR__));
/**
* The actual directory name for the application directory. Normally
* named 'src'.
*/
define('APP_DIR', 'src');
/**
* Path to the application's directory.
*/
define('APP', ROOT . DS . APP_DIR . DS);
/**
* Path to the config directory.
*/
define('CONFIG', ROOT . DS . 'config' . DS);
/**
* File path to the webroot directory.
*
* To derive your webroot from your webserver change this to:
*
* `define('WWW_ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], DS) . DS);`
*/
define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
/**
* Path to the tests directory.
*/
define('TESTS', ROOT . DS . 'tests' . DS);
/**
* Path to the temporary files directory.
*/
define('TMP', ROOT . DS . 'tmp' . DS);
/**
* Path to the logs directory.
*/
define('LOGS', ROOT . DS . 'logs' . DS);
/**
* Path to the cache files directory. It can be shared between hosts in a multi-server setup.
*/
define('CACHE', TMP . 'cache' . DS);
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*
* CakePHP should always be installed with composer, so look there.
*/
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
/**
* Path to the cake directory.
*/
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
define('CAKE', CORE_PATH . 'src' . DS);

View File

@ -1,2 +0,0 @@
#upload_max_filesize = 100M
#post_max_size = 108M

View File

@ -1,39 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.5.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
/*
* You can empty out this file, if you are certain that you match all requirements.
*/
/*
* You can remove this if you are confident that your PHP version is sufficient.
*/
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
/*
* You can remove this if you are confident you have intl installed.
*/
if (!extension_loaded('intl')) {
trigger_error('You must enable the intl extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
/*
* You can remove this if you are confident you have mbstring installed.
*/
if (!extension_loaded('mbstring')) {
trigger_error('You must enable the mbstring extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}

View File

@ -1,25 +0,0 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
return [
'inputContainer' => '{{content}}',
'input' => '<div class="input-group showcase_row_area">'
. '<input type="{{type}}" class="form-control" name="{{name}}"{{attrs}}/>'
. '</div>',
'error' => '<div class="input-group showcase_content_area invalid-feedback">'
. '{{content}}'
. '</div>',
// Container for error items.
//'errorList' => '<ul>{{content}}</ul>',
'errorList' => '{{content}}',
// Error item wrapper.
//'errorItem' => '<li>{{text}}</li>',
'errorItem' => '<div>{{text}}</div>'
];

View File

@ -1,160 +0,0 @@
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different URLs to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Http\Middleware\CsrfProtectionMiddleware;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;
use Cake\Core\Configure;
/**
* The default class to use for all routes
*
* The following route classes are supplied with CakePHP and are appropriate
* to set as the default:
*
* - Route
* - InflectedRoute
* - DashedRoute
*
* If no call is made to `Router::defaultRouteClass()`, the class used is
* `Route` (`Cake\Routing\Route\Route`)
*
* Note that `Route` does not do any inflections on URLs which will result in
* inconsistently cased URLs when used with `:plugin`, `:controller` and
* `:action` markers.
*
* Cache: Routes are cached to improve performance, check the RoutingMiddleware
* constructor in your `src/Application.php` file to change this behavior.
*
*/
Router::defaultRouteClass(DashedRoute::class);
Router::scope('/', function (RouteBuilder $routes) {
$csrf = new CsrfProtectionMiddleware([
'httpOnly' => true
]);
// Token check will be skipped when callback returns `true`.
$csrf->whitelistCallback(function ($request) {
// Skip token check for API URLs.
//die($request->getParam('controller'));
$whitelist = ['JsonRequestHandler', 'ElopageWebhook', 'AppRequests'];
$ajaxWhitelist = ['TransactionSendCoins', 'TransactionCreations'];
$callerIp = $request->clientIp();
foreach($whitelist as $entry) {
if($request->getParam('controller') === $entry) {
if($entry == 'ElopageWebhook' || $entry == 'AppRequests') {
return true;
}
$allowedIpLocalhost = ['127.0.0.1', 'localhost', '', '::1'];
if(in_array($callerIp, $allowedIpLocalhost)) {
return true;
}
$allowedCaller = Configure::read('API.allowedCaller');
$ipPerHost = [];
if($allowedCaller && count($allowedCaller) > 0) {
foreach($allowedCaller as $allowed) {
$ip = gethostbyname($allowed);
$ipPerHost[$allowed] = $ip;
if($ip === $callerIp) return true;
}
//die("caller ip: $callerIp<br>");
}
//var_dump(['caller_ip' => $callerIp, 'ips' => $ipPerHost]);
die(json_encode(['state' => 'error', 'details' => ['caller_ip' => $callerIp, 'ips' => $ipPerHost]]));
}
}
// disable csfr for all ajax requests in ajax whitelisted controller
foreach($ajaxWhitelist as $entry) {
if($request->getParam('controller') === $entry) {
$action = $request->getParam('action');
if(preg_match('/^ajax/', $action)) {
return true;
}
}
}
});
// Register scoped middleware for in scopes.
$routes->registerMiddleware('csrf', $csrf);
/**
* Apply a middleware to the current route scope.
* Requires middleware to be registered via `Application::routes()` with `registerMiddleware()`
*/
$routes->applyMiddleware('csrf');
/**
* Here, we are connecting '/' (base path) to a controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, src/Template/Pages/home.ctp)...
*/
//$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
$routes->connect('/', ['controller' => 'Dashboard', 'action' => 'index']);
$routes->connect('/api/:action/*', ['controller' => 'AppRequests'], ['routeClass' => 'DashedRoute']);
//$routes->connect('/client', ['controller' => 'Pages', 'action' => 'display', 'js']);
$routes->connect('/server', ['controller' => 'Dashboard', 'action' => 'serverIndex']);
$routes->connect('/client', ['controller' => 'Pages', 'action' => 'display', 'vue']);
$routes->connect('/vue-dev', ['controller' => 'Pages', 'action' => 'display', 'vue-dev']);
//$routes->connect('/', 'https://gradido2.dario-rekowski.de/account', array('status' => 303));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
/**
* Connect catchall routes for all controllers.
*
* Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
*
* ```
* $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);
* $routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);
* ```
*
* Any route class can be used with this method, such as:
* - DashedRoute
* - InflectedRoute
* - Route
* - Or your own route class
*
* You can remove these routes once you've connected the
* routes you want in your application.
*/
$routes->fallbacks(DashedRoute::class);
});
/**
* If you need a different set of middleware or none at all,
* open new scope and define routes there.
*
* ```
* Router::scope('/api', function (RouteBuilder $routes) {
* // No $routes->applyMiddleware() here.
* // Connect API actions here.
* });
* ```
*/

View File

@ -1,18 +0,0 @@
# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
#
# Licensed under The MIT License
# For full copyright and license information, please see the LICENSE.txt
# Redistributions of files must retain the above copyright notice.
# MIT License (https://opensource.org/licenses/mit-license.php)
CREATE TABLE i18n (
id int NOT NULL auto_increment,
locale varchar(6) NOT NULL,
model varchar(255) NOT NULL,
foreign_key int(10) NOT NULL,
field varchar(255) NOT NULL,
content text,
PRIMARY KEY (id),
UNIQUE INDEX I18N_LOCALE_FIELD(locale, model, foreign_key, field),
INDEX I18N_FIELD(model, foreign_key, field)
);

View File

@ -1,15 +0,0 @@
# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
#
# Licensed under The MIT License
# For full copyright and license information, please see the LICENSE.txt
# Redistributions of files must retain the above copyright notice.
# MIT License (https://opensource.org/licenses/mit-license.php)
CREATE TABLE `sessions` (
`id` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`created` datetime DEFAULT CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
`modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
`data` blob DEFAULT NULL, -- for PostgreSQL use bytea instead of blob
`expires` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,38 +0,0 @@
#!/bin/bash
[! -z "${FOLDER_NAME}"] && FOLDER_NAME=community_server
COLOR_GREEN="\033[0;32m"
COLOR_YELLOW="\e[33m"
COLOR_NONE="\033[0m"
SCRIPT=`realpath -s $0`
SCRIPTPATH=`dirname $SCRIPT`
#echo -e "script: $SCRIPT, Path: $SCRIPTPATH "
cd /var/www/html
if [ ! -d "$FOLDER_NAME" ] ; then
mkdir $FOLDER_NAME
else
chmod -R 0755 $FOLDER_NAME
fi
cd $FOLDER_NAME
cp -r $SCRIPTPATH/src .
cp -r $SCRIPTPATH/config .
cp -r $SCRIPTPATH/composer.json .
cp -r $SCRIPTPATH/webroot .
composer install
if [ ! -d "tmp" ] ; then
mkdir tmp
chown -R www-data:www-data ./tmp
fi
if [ ! -d "logs" ] ; then
mkdir logs
chown -R www-data:www-data ./logs
fi
cd ..
chown -R www-data:www-data $FOLDER_NAME
chmod -R 0755 $FOLDER_NAME/src
chmod -R 0755 $FOLDER_NAME/config
chmod -R 0755 $FOLDER_NAME/webroot

View File

@ -1,132 +0,0 @@
# community server api
In this examples I assume that you use gradido with docker-compose build on your local maschine
## Konto Overview
return current account balance
GET http://localhost/state-balances/ajaxGetBalance/-127182
If session is valid, return:
```json
{"state":"success","balance":174500}
```
- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 174500 = 17,45 GDD
## List Transactions
List all transactions from logged in user, currently without paging
Ajax:
GET http://localhost/state-balances/ajaxListTransactions/-127182/
or
GET http://localhost/state-balances/ajaxListTransactions/-127182/DESC
to get transaction in descending order
Antwort:
Wenn alles okay:
```json
{"state":"success", "transactions":
[
{
"name": "Max Mustermann",
"email": "Maxim Mustermann",
"type": "send",
"transaction_id": 2,
"date": "2021-02-19T13:25:36+00:00",
"balance": 1920000,
"memo": "a piece of cake :)",
"pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7"
}
],
"transactionExecutingCount": 0,
"count": 1,
"gdtSum": 0,
"timeUsed": 0.04562687873840332
}
```
- name: name of other involved party or empty if unknown (if other party don't belong to group)
- if type is send, name is name of receiver
- if type is receive, name is name of sender
- if type is creation currently I use a static string ("Gradido Akademie)
- email: optional, only if type is send or receive and other user is known
- pubkey: optional, only if type is send or receive and other user isn't known
- type: type of transaction
- creation: user has get gradidos created
- send: user has send another user gradidos
- receiver: user has received gradidos from another user
- transaction_id: id of transaction in db, in stage2 also the hedera sequence number of transaction
- date: date of ordering transaction (booking date)
- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 1920000 = 192,00 GDD
- memo: Details about transaction
- pubkey: optional, if other party isn't known, hexadecimal representation of 32 Byte public key of user [0-9a-f]
- transactionExecutingCount: how many transaction for this user currently pending and waiting for signing
- count: sum of finished transactions user is involved
- gdtSum: sum of gdt of user in cent with 2 places (Nachkommastellen)
- timeUsed: time used for getting data from db in seconds, only for analyse backend performance
## Creation Transaction
Make a creation transaction
With new Option set in Login-Server:
```ini
unsecure.allow_auto_sign_transactions = 1
```
transactions can be auto-signed directly with handing in transaction.
Normally a forwarding to login-server check transactions side is neccessary to minimize security risks.
POST http://localhost/transaction-creations/ajaxCreate
```json
{
"session_id" : -127182,
"email": "max.musterman@gmail.de",
"amount": 10000000,
"target_date":"2021-02-19T13:25:36+00:00",
"memo":"AGE",
"auto_sign": true
}
```
return if everything is ok:
```json
{"state":"success", "timeUsed": 0.0122}
```
- timeUsed: time used for getting data from db in seconds, only for analyse backend performance
## Send Coins Transaction
Make a simple GDD Transaction, send Coins from one user to other.
With new Option set in Login-Server:
```ini
unsecure.allow_auto_sign_transactions = 1
```
transactions can be auto-signed directly with handing in transaction.
Normally a forwarding to login-server check transactions side is neccessary to minimize security risks.
POST http://localhost/transaction-send-coins/ajaxCreate
```json
{
"session_id" : -127182,
"amount": 2000000,
"email": "max.musterman@gmail.de",
"memo":"Thank you :)",
"auto_sign": true
}
```
- amout: amount to transfer, 2000000 = 200,00 GDD
- email: receiver email address, must be differ from user email
- memo: Details about transaction
- auto_sign: set to true to directly sign transaction if unsecure.allow_auto_sign_transactions = 1 is set
return if everything is ok:
```json
{"state":"success", "timeUsed": 0.0122}
```
- timeUsed: time used for getting data from db in seconds, only for analyse backend performance
Than the transaction was created on community server, send to login-server, signed (if unsecure.allow_auto_sign_transactions = 1 and auto_sign = true)
and send back to community server and put into db.
After you get this answear you see the new transaction if you list transactions or call for the balance.
Without auto-sign the transaction is pending on login-server and waits for the user to review it at
http://localhost/account/checkTransactions

View File

@ -1,16 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.10.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
#!/bin/bash
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# need grpc only for hedera hashgraph
#PHP_PLUGIN="$(which grpc_php_plugin)"
#protoc --proto_path=./src/protobuf/gradido --php_out=./src/ --grpc_out=./src/ --plugin=protoc-gen-grpc=$PHP_PLUGIN ./src/protobuf/gradido/*.proto
protoc --proto_path=./src/protobuf --php_out=./src/Model/Messages ./src/protobuf/gradido/*.proto

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="app">
<directory>tests/TestCase/</directory>
</testsuite>
<!-- Add plugin test suites here. -->
</testsuites>
<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<!-- Ignore vendor tests in code coverage reports -->
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<directory suffix=".php">plugins/*/src/</directory>
<exclude>
<file>src/Console/Installer.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@ -1,117 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.3.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App;
use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException;
use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\BaseApplication;
use Cake\Http\Middleware\CsrfProtectionMiddleware;
use Cake\Routing\Middleware\AssetMiddleware;
use Cake\Routing\Middleware\RoutingMiddleware;
/**
* Application setup class.
*
* This defines the bootstrapping logic and middleware layers you
* want to use in your application.
*/
class Application extends BaseApplication
{
/**
* {@inheritDoc}
*/
public function bootstrap()
{
// Call parent to load bootstrap from files.
parent::bootstrap();
if (PHP_SAPI === 'cli') {
$this->bootstrapCli();
}
/*
* Only try to load DebugKit in development mode
* Debug Kit should not be installed on a production system
*/
if (Configure::read('debug')) {
$this->addPlugin(\DebugKit\Plugin::class);
}
// Load more plugins here
}
/**
* Setup the middleware queue your application will use.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup.
* @return \Cake\Http\MiddlewareQueue The updated middleware queue.
*/
public function middleware($middlewareQueue)
{
//$csrf = new CsrfProtectionMiddleware();
// Token check will be skipped when callback returns `true`.
/*$csrf->whitelistCallback(function ($request) {
// Skip token check for API URLs.
//if ($request->getParam('prefix') === 'api') {
if($request->getAttribute('base') === 'TransactionJsonRequestHandler') {
return true;
}
});
*/
// Ensure routing middleware is added to the queue before CSRF protection middleware.
//$middlewareQueue->;
$middlewareQueue
// ->add($csrf)
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(new ErrorHandlerMiddleware(null, Configure::read('Error')))
// Handle plugin/theme assets like CakePHP normally does.
->add(new AssetMiddleware([
'cacheTime' => Configure::read('Asset.cacheTime')
]))
// Add routing middleware.
// If you have a large number of routes connected, turning on routes
// caching in production could improve performance. For that when
// creating the middleware instance specify the cache config name by
// using it's second constructor argument:
// `new RoutingMiddleware($this, '_cake_routes_')`
->add(new RoutingMiddleware($this));
return $middlewareQueue;
}
/**
* @return void
*/
protected function bootstrapCli()
{
try {
$this->addPlugin('Bake');
} catch (MissingPluginException $e) {
// Do not halt if the plugin is missing
}
// Load more plugins here
}
}

View File

@ -1,246 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Console;
if (!defined('STDIN')) {
define('STDIN', fopen('php://stdin', 'r'));
}
use Cake\Utility\Security;
use Composer\Script\Event;
use Exception;
/**
* Provides installation hooks for when this application is installed via
* composer. Customize this class to suit your needs.
*/
class Installer
{
/**
* An array of directories to be made writable
*/
const WRITABLE_DIRS = [
'logs',
'tmp',
'tmp/cache',
'tmp/cache/models',
'tmp/cache/persistent',
'tmp/cache/views',
'tmp/sessions',
'tmp/tests'
];
/**
* Does some routine installation tasks so people don't have to.
*
* @param \Composer\Script\Event $event The composer event object.
* @throws \Exception Exception raised by validator.
* @return void
*/
public static function postInstall(Event $event)
{
$io = $event->getIO();
$rootDir = dirname(dirname(__DIR__));
static::createAppConfig($rootDir, $io);
static::createWritableDirectories($rootDir, $io);
// ask if the permissions should be changed
if ($io->isInteractive()) {
$validator = function ($arg) {
if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
return $arg;
}
throw new Exception('This is not a valid answer. Please choose Y or n.');
};
$setFolderPermissions = $io->askAndValidate(
'<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',
$validator,
10,
'Y'
);
if (in_array($setFolderPermissions, ['Y', 'y'])) {
static::setFolderPermissions($rootDir, $io);
}
} else {
static::setFolderPermissions($rootDir, $io);
}
static::setSecuritySalt($rootDir, $io);
$class = 'Cake\Codeception\Console\Installer';
if (class_exists($class)) {
$class::customizeCodeceptionBinary($event);
}
}
/**
* Create the config/app.php file if it does not exist.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function createAppConfig($dir, $io)
{
$appConfig = $dir . '/config/app.php';
$defaultConfig = $dir . '/config/app.default.php';
if (!file_exists($appConfig)) {
copy($defaultConfig, $appConfig);
$io->write('Created `config/app.php` file');
}
}
/**
* Create the `logs` and `tmp` directories.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function createWritableDirectories($dir, $io)
{
foreach (static::WRITABLE_DIRS as $path) {
$path = $dir . '/' . $path;
if (!file_exists($path)) {
mkdir($path);
$io->write('Created `' . $path . '` directory');
}
}
}
/**
* Set globally writable permissions on the "tmp" and "logs" directory.
*
* This is not the most secure default, but it gets people up and running quickly.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function setFolderPermissions($dir, $io)
{
// Change the permissions on a path and output the results.
$changePerms = function ($path) use ($io) {
$currentPerms = fileperms($path) & 0777;
$worldWritable = $currentPerms | 0007;
if ($worldWritable == $currentPerms) {
return;
}
$res = chmod($path, $worldWritable);
if ($res) {
$io->write('Permissions set on ' . $path);
} else {
$io->write('Failed to set permissions on ' . $path);
}
};
$walker = function ($dir) use (&$walker, $changePerms) {
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
$path = $dir . '/' . $file;
if (!is_dir($path)) {
continue;
}
$changePerms($path);
$walker($path);
}
};
$walker($dir . '/tmp');
$changePerms($dir . '/tmp');
$changePerms($dir . '/logs');
}
/**
* Set the security.salt value in the application's config file.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function setSecuritySalt($dir, $io)
{
$newKey = hash('sha256', Security::randomBytes(64));
static::setSecuritySaltInFile($dir, $io, $newKey, 'app.php');
}
/**
* Set the security.salt value in a given file
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @param string $newKey key to set in the file
* @param string $file A path to a file relative to the application's root
* @return void
*/
public static function setSecuritySaltInFile($dir, $io, $newKey, $file)
{
$config = $dir . '/config/' . $file;
$content = file_get_contents($config);
$content = str_replace('__SALT__', $newKey, $content, $count);
if ($count == 0) {
$io->write('No Security.salt placeholder to replace.');
return;
}
$result = file_put_contents($config, $content);
if ($result) {
$io->write('Updated Security.salt value in config/' . $file);
return;
}
$io->write('Unable to update Security.salt value.');
}
/**
* Set the APP_NAME value in a given file
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @param string $appName app name to set in the file
* @param string $file A path to a file relative to the application's root
* @return void
*/
public static function setAppNameInFile($dir, $io, $appName, $file)
{
$config = $dir . '/config/' . $file;
$content = file_get_contents($config);
$content = str_replace('__APP_NAME__', $appName, $content, $count);
if ($count == 0) {
$io->write('No __APP_NAME__ placeholder to replace.');
return;
}
$result = file_put_contents($config, $content);
if ($result) {
$io->write('Updated __APP_NAME__ value in config/' . $file);
return;
}
$io->write('Unable to update __APP_NAME__ value.');
}
}

View File

@ -1,106 +0,0 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* AddressTypes Controller
*
* @property \App\Model\Table\AddressTypesTable $AddressTypes
*
* @method \App\Model\Entity\AddressType[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class AddressTypesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$addressTypes = $this->paginate($this->AddressTypes);
$this->set(compact('addressTypes'));
}
/**
* View method
*
* @param string|null $id Address Type id.
* @return \Cake\Http\Response|null
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$addressType = $this->AddressTypes->get($id, [
'contain' => ['StateGroupAddresses', 'TransactionGroupAddaddress'],
]);
$this->set('addressType', $addressType);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$addressType = $this->AddressTypes->newEntity();
if ($this->request->is('post')) {
$addressType = $this->AddressTypes->patchEntity($addressType, $this->request->getData());
if ($this->AddressTypes->save($addressType)) {
$this->Flash->success(__('The address type has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The address type could not be saved. Please, try again.'));
}
$this->set(compact('addressType'));
}
/**
* Edit method
*
* @param string|null $id Address Type id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
$addressType = $this->AddressTypes->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$addressType = $this->AddressTypes->patchEntity($addressType, $this->request->getData());
if ($this->AddressTypes->save($addressType)) {
$this->Flash->success(__('The address type has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The address type could not be saved. Please, try again.'));
}
$this->set(compact('addressType'));
}
/**
* Delete method
*
* @param string|null $id Address Type id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$addressType = $this->AddressTypes->get($id);
if ($this->AddressTypes->delete($addressType)) {
$this->Flash->success(__('The address type has been deleted.'));
} else {
$this->Flash->error(__('The address type could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -1,111 +0,0 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* AdminErrors Controller
*
* @property \App\Model\Table\AdminErrorsTable $AdminErrors
*
* @method \App\Model\Entity\AdminError[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class AdminErrorsController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$this->paginate = [
'contain' => ['StateUsers']
];
$adminErrors = $this->paginate($this->AdminErrors);
$this->set(compact('adminErrors'));
}
/**
* View method
*
* @param string|null $id Admin Error id.
* @return \Cake\Http\Response|null
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$adminError = $this->AdminErrors->get($id, [
'contain' => ['StateUsers']
]);
$this->set('adminError', $adminError);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$adminError = $this->AdminErrors->newEntity();
if ($this->request->is('post')) {
$adminError = $this->AdminErrors->patchEntity($adminError, $this->request->getData());
if ($this->AdminErrors->save($adminError)) {
$this->Flash->success(__('The admin error has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The admin error could not be saved. Please, try again.'));
}
$stateUsers = $this->AdminErrors->StateUsers->find('list', ['limit' => 200]);
$this->set(compact('adminError', 'stateUsers'));
}
/**
* Edit method
*
* @param string|null $id Admin Error id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
$adminError = $this->AdminErrors->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$adminError = $this->AdminErrors->patchEntity($adminError, $this->request->getData());
if ($this->AdminErrors->save($adminError)) {
$this->Flash->success(__('The admin error has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The admin error could not be saved. Please, try again.'));
}
$stateUsers = $this->AdminErrors->StateUsers->find('list', ['limit' => 200]);
$this->set(compact('adminError', 'stateUsers'));
}
/**
* Delete method
*
* @param string|null $id Admin Error id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$adminError = $this->AdminErrors->get($id);
if ($this->AdminErrors->delete($adminError)) {
$this->Flash->success(__('The admin error has been deleted.'));
} else {
$this->Flash->error(__('The admin error could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -1,386 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.2.9
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Controller;
use Cake\Controller\Controller;
//use Cake\Event\Event;
use Cake\Http\Client;
use Cake\Routing\Router;
use Cake\ORM\TableRegistry;
use Cake\Core\Configure;
use Cake\I18n\Time;
use Cake\I18n\FrozenTime;
/**
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @link https://book.cakephp.org/3.0/en/controllers.html#the-app-controller
*/
class AppController extends Controller
{
var $loginServerUrl = '';
var $blockchainType = 'mysql';
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler', [
'enableBeforeRedirect' => false,
]);
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'loginAction' => [
'controller' => 'ServerUsers',
'action' => 'login'
],
'loginRedirect' => [
'controller' => 'Transactions',
'action' => 'index'
],
'logoutRedirect' => [
'controller' => 'Pages',
'action' => 'display',
'gradido'
],
'authenticate' => [
'all' => ['userModel' => 'ServerUsers'],
'Form' => [
'userModel' => 'ServerUsers',
]
]
]);
$this->Auth->deny(['index']);
/*
* Enable the following component for recommended CakePHP security settings.
* see https://book.cakephp.org/3.0/en/controllers/components/security.html
*/
//$this->loadComponent('Security');
// load current balance
$session = $this->getRequest()->getSession();
$state_user_id = $session->read('StateUser.id');
// load error count
if ($state_user_id) {
$stateErrorsTable = TableRegistry::getTableLocator()->get('stateErrors');
$stateErrorQuery = $stateErrorsTable
->find('all')
->select('id')
->contain(false)
->where(['state_user_id' => $state_user_id]);
$session->write('StateUser.errorCount', $stateErrorQuery->count());
}
// put current page into global for navi
$GLOBALS["passed"] = null;
$side = $this->request->getParam('controller');
$GLOBALS["side"] = $side;
$subside = $this->request->getParam('action');
$passedArguments = $this->request->getParam('pass');
if ($passedArguments) {
$GLOBALS["passed"] = $passedArguments[0];
}
$GLOBALS["subside"] = $subside;
// server login
if ($this->Auth->user('id')) {
$GLOBALS['ServerUser'] = $this->Auth->user();
}
// login server url
$loginServer = Configure::read('LoginServer');
if ($loginServer && isset($loginServer['url'])) {
$this->loginServerUrl = $loginServer['url'] . '/';
} else {
$this->loginServerUrl = Router::url('/', true);
}
/*
*
* 'GradidoBlockchain' => [
* // type:
* // - mysql: centralized blockchain in mysql db, no cross group transactions
* // - hedera: send transaction over hedera
* 'type' => 'hedera',
* // gradido nodes with blockchain (if type != mysql)
* 'nodes' => [
* ['host' => 'http://192.168.178.225', 'port' => 13702]
* ]
* ],
*/
$blockchain = Configure::read('GradidoBlockchain');
if($blockchain && isset($blockchain['type'])) {
$this->blockchainType = $blockchain['type'];
}
}
protected function requestLogin($sessionId = 0, $redirect = true)
{
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
$session = $this->getRequest()->getSession();
// check login
// disable encryption for cookies
$session_id = 0;
$php_session_id = 0;
if($session->check('session_id')) {
$php_session_id = intval($session->read('session_id'));
}
$cookie_session_id = intval($this->request->getCookie('GRADIDO_LOGIN', ''));
// decide in which order session_ids are tried
if($sessionId != 0) {
$session_id = $sessionId;
} else if($php_session_id != 0) {
$session_id = $php_session_id;
} else if($cookie_session_id != 0) {
$session_id = $cookie_session_id;
}
$ip = $this->request->clientIp();
if (!$session->check('client_ip')) {
$session->write('client_ip', $ip);
}
// login server cannot detect host ip
// TODO: update login server, recognize nginx real ip header
$loginServer = Configure::read('LoginServer');
if ($session_id != 0) {
$userStored = $session->read('StateUser');
$transactionPendings = $session->read('Transactions.pending');
$transactionExecutings = $session->read('Transactions.executing');
$transaction_can_signed = $session->read('Transactions.can_signed');
if ($session->read('session_id') != $session_id ||
( $userStored && (!isset($userStored['id']) || !$userStored['email_checked'])) ||
intval($transactionPendings) > 0 ||
intval($transactionExecutings) > 0 ||
intval($transaction_can_signed > 0))
{
$http = new Client();
try {
$url = $loginServer['host'] . ':' . $loginServer['port'];
$response = $http->get($url . '/login', ['session_id' => $session_id]);
$json = $response->getJson();
if (isset($json) && count($json) > 0) {
if ($json['state'] === 'success') {
//echo "email checked: " . $json['user']['email_checked'] . "; <br>";
if ($session->read('session_id') != $session_id ||
( $userStored && !isset($userStored['id']))) {
$session->destroy();
}
foreach ($json['user'] as $key => $value) {
// we don't need the id of user in login server db
if($key == 'id') continue;
$session->write('StateUser.' . $key, $value);
}
//var_dump($json);
$transactionPendings = $json['Transactions.pending'];
$transactionExecuting = $json['Transactions.executing'];
$transaction_can_signed = $json['Transactions.can_signed'];
//echo "read transaction pending: $transactionPendings<br>";
$session->write('Transactions.pending', $transactionPendings);
$session->write('Transactions.executing', $transactionExecuting);
$session->write('Transactions.can_signed', $transaction_can_signed);
$session->write('session_id', $session_id);
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
if (isset($json['user']['public_hex']) && $json['user']['public_hex'] != '') {
$public_key_bin = hex2bin($json['user']['public_hex']);
$stateUserQuery = $stateUserTable
->find('all')
->where(['public_key' => $public_key_bin])
->contain('StateBalances', function ($q) {
return $q->order(['record_date' => 'DESC'])
->limit(1);
});
if ($stateUserQuery->count() == 1) {
$stateUser = $stateUserQuery->first();
if ($stateUser->first_name != $json['user']['first_name'] ||
$stateUser->last_name != $json['user']['last_name'] ||
$stateUser->disabled != $json['user']['disabled'] ||
//$stateUser->username != $json['user']['username'] ||
// -> throws error
$stateUser->email != $json['user']['email']
) {
$stateUser->first_name = $json['user']['first_name'];
$stateUser->last_name = $json['user']['last_name'];
$stateUser->disabled = intval($json['user']['disabled']);
//$stateUser->username = $json['user']['username'];
$stateUser->email = $json['user']['email'];
if (!$stateUserTable->save($stateUser)) {
$this->Flash->error(__('error updating state user ' . json_encode($stateUser->errors())));
}
}
$session->write('StateUser.id', $stateUser->id);
//echo $stateUser['id'];
} else {
$newStateUser = $stateUserTable->newEntity();
$newStateUser->public_key = $public_key_bin;
$newStateUser->first_name = $json['user']['first_name'];
$newStateUser->last_name = $json['user']['last_name'];
$newStateUser->disabled = intval($json['user']['disabled']);
//$newStateUser->username = $json['user']['username'];
$newStateUser->email = $json['user']['email'];
if (!$stateUserTable->save($newStateUser)) {
$this->Flash->error(__('error saving state user ' . json_encode($newStateUser->errors())));
}
$session->write('StateUser.id', $newStateUser->id);
//echo $newStateUser->id;
}
} else {
if(!$redirect) {
return ['state' => 'error', 'msg' => 'no pubkey'];
}
// we haven't get a pubkey? something seems to gone wrong on the login-server
$this->Flash->error(__('no pubkey'));
//var_dump($json);
return $this->redirect($this->loginServerUrl . 'account/error500/noPubkey', 303);
}
} else {
if(!$redirect) {
return ['state' => 'not found', 'msg' => 'invalid session', 'details' => $json];
}
if ($json['state'] === 'not found') {
$this->Flash->error(__('invalid session'));
} else {
$this->Flash->error(__('Konto ist nicht aktiviert!'));
}
//die(json_encode($json));
if(preg_match('/client ip/', $json['msg'])) {
return $this->redirect($this->loginServerUrl . 'account/error500/ipError', 303);
}
return $this->redirect($this->loginServerUrl . 'account/', 303);
}
}
} catch (\Exception $e) {
$msg = $e->getMessage();
if(!$redirect) {
return ['state' => 'error', 'msg' => 'login-server http request error', 'details' => $msg];
}
$this->Flash->error(__('error http request: ') . $msg);
return $this->redirect(['controller' => 'Dashboard', 'action' => 'errorHttpRequest']);
//continue;
}
}
$state_balance = $stateBalancesTable->find()->where(['state_user_id' => $session->read('StateUser.id')])->first();
if ($state_balance) {
$now = new FrozenTime;
$session->write('StateUser.balance', $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now));
}
} else {
// no login
//die("no login");
if(!$redirect) {
return ['state' => 'error', 'msg' => 'not logged in'];
}
if (isset($loginServer['path'])) {
return $this->redirect($loginServer['path'], 303);
} else {
return $this->redirect($this->loginServerUrl . 'account/', 303);
}
}
return true;
}
/*
public function beforeFilter(Event $event)
{
//$this->Auth->allow(['display']);
}
*/
public function addAdminError($controller, $action, array $returnTable, $state_user_id)
{
if (!is_array($returnTable)) {
$this->addAdminError('AppController', 'addAdminError', ['state' => 'error', 'msg' => 'returnTable isn\'t array', 'details' => gettype($returnTable)], $state_user_id);
return false;
}
$adminErrorTable = TableRegistry::getTableLocator()->get('AdminErrors');
$adminErrorEntity = $adminErrorTable->newEntity();
$adminErrorEntity->state_user_id = $state_user_id;
$adminErrorEntity->controller = $controller;
$adminErrorEntity->action = $action;
$adminErrorEntity->state = $returnTable['state'];
if (isset($returnTable['msg'])) {
$adminErrorEntity->msg = $returnTable['msg'];
} else {
$adminErrorEntity->msg = __('(Leere Message)');
}
if (isset($returnTable['details'])) {
$adminErrorEntity->details = $returnTable['details'];
} else {
$adminErrorEntity->details = __('(Leere Details)');
}
if (!$adminErrorTable->save($adminErrorEntity)) {
$this->Flash->error(
__('Serious error, couldn\'t save to db, please write the admin: ' . $this->getAdminEmailLink()),
['escape' => false]
);
}
return true;
}
public function getAdminEmailLink($text = '')
{
$serverAdminEmail = Configure::read('ServerAdminEmail');
return '<a href="mailto:' . $serverAdminEmail . '">'. $serverAdminEmail . '</a>';
}
public function returnJsonEncoded($json)
{
$this->autoRender = false;
$response = $this->response->withType('application/json');
return $response->withStringBody($json);
}
public function returnJson($array)
{
$this->autoRender = false;
$response = $this->response->withType('application/json');
return $response->withStringBody(json_encode($array));
}
public function getStartEndForMonth($month, $year)
{
$timeString = $year . '-' . $month . '-01 00:00';
$firstDay = new Time($timeString);
$lastDay = new Time($timeString);
$lastDay = $lastDay->addMonth(1);
return [$firstDay, $lastDay];
}
}

View File

@ -1,465 +0,0 @@
<?php
/*!
* @author: Dario Rekowski
* @date : 2020-12-01
* @brief: Controller for all ajax-json requests caming from mobile app
*
* Everything is allowed to call them, so caution!
*/
namespace App\Controller;
use App\Controller\AppController;
use Cake\ORM\TableRegistry;
use Cake\Http\Client;
use Cake\Core\Configure;
use Cake\I18n\FrozenTime;
class AppRequestsController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadComponent('JsonRequestClient');
$this->loadComponent('GradidoNumber');
//$this->loadComponent('JsonRpcRequestClient');
//$this->Auth->allow(['add', 'edit']);
$this->Auth->allow([
'index', 'sendCoins', 'createCoins', 'getBalance',
'listTransactions','listGDTTransactions', 'getDecayStartBlock'
]);
}
public function index()
{
if($this->request->is('get')) {
$method = $this->request->getQuery('method');
switch($method) {
}
return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for get', 'details' => $method]);
}
else if($this->request->is('post')) {
$jsonData = $this->request->input('json_decode');
//var_dump($jsonData);
if($jsonData == NULL || !isset($jsonData->method)) {
return $this->returnJson(['state' => 'error', 'msg' => 'parameter error']);
}
$method = $jsonData->method;
switch($method) {
}
return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for post', 'details' => $method]);
}
return $this->returnJson(['state' => 'error', 'msg' => 'no post or get']);
}
private function checkAndCopyRequiredFields($fields, &$param, $data = null) {
if($data == null) {
$data = $this->request->input('json_decode');
}
foreach($fields as $field) {
if(is_array($field)) {
$one_exist = false;
foreach($field as $oneField) {
if(isset($data->$oneField)) {
$param[$oneField] = $data->$oneField;
$one_exist = true;
break;
}
}
if(!$one_exist) {
return ['state' => 'error', 'msg' => 'missing field of set', 'details' => $field];
}
} else {
if(!isset($data->$field)) {
return ['state' => 'error', 'msg' => 'missing field', 'details' => $field . ' not found'];
} else {
$param[$field] = $data->$field;
}
}
}
return true;
}
private function rewriteKeys(&$data, $replaceKeys)
{
foreach(array_keys($replaceKeys) as $key) {
$newKey = $replaceKeys[$key];
if(isset($data->$key)) {
$data->$newKey = $data->$key;
unset($data->$key);
}
}
}
private function parseParameterForCreateTransaction(&$param, $data = null)
{
if($data == null) {
$data = $this->request->input('json_decode');
}
$session_id = 0;
if(isset($data->session_id)) {
$session_id = $data->session_id;
}
$login_request_result = $this->requestLogin($session_id, false);
if($login_request_result !== true) {
return $login_request_result;
}
$session = $this->getRequest()->getSession();
$param['session_id'] = $session->read('session_id');
$param['blockchain_type'] = $this->blockchainType;
$this->rewriteKeys($data, ['email' => 'target_email', 'username' => 'target_username', 'pubkey' => 'target_pubkey']);
$required_fields = $this->checkAndCopyRequiredFields(['amount', ['target_email', 'target_username', 'target_pubkey']], $param, $data);
if($required_fields !== true) {
return $required_fields;
}
if(floatval($param['amount']) <= 0.0) {
return ['state' => 'error', 'msg' => 'amount is invalid', 'details' => $param['amount']];
}
$param['amount'] = $this->GradidoNumber->parseInputNumberToCentNumber($param['amount']);
if(isset($data->memo)) {
$param['memo'] = $data->memo;
}
if(isset($data->auto_sign)) {
$param['auto_sign'] = boolval($data->auto_sign);
}
return true;
}
public function sendCoins()
{
/*
* {
"session_id" : -127182,
"amount": 2000000,
"email": "max.musterman@gmail.de",
"memo":"Thank you :)",
"group": "gdd1",
"auto_sign": true
*/
if(!$this->request->is('post')) {
return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
}
$data = $this->request->input('json_decode');
$params = [];
$result = $this->parseParameterForCreateTransaction($params, $data);
if($result !== true) {
return $this->returnJson($result);
}
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]']);
}
$params['transaction_type'] = 'transfer';
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode($params), '/createTransaction');
if('success' == $requestAnswear['state'] && 'success' == $requestAnswear['data']['state']) {
$session = $this->getRequest()->getSession();
$pendingTransactionCount = $session->read('Transactions.pending');
if($pendingTransactionCount == null) {
$pendingTransactionCount = 1;
} else {
$pendingTransactionCount++;
}
$session->write('Transactions.pending', $pendingTransactionCount);
//echo "pending: " . $pendingTransactionCount;
return $this->returnJson(['state' => 'success']);
} else {
/*
* if request contain unknown parameter format, shouldn't happen't at all
* {"state": "error", "msg": "parameter format unknown"}
* if json parsing failed
* {"state": "error", "msg": "json exception", "details":"exception text"}
* if session_id is zero or not set
* {"state": "error", "msg": "session_id invalid"}
* if session id wasn't found on login server, if server was restartet or user logged out (also per timeout, default: 15 minutes)
* {"state": "error", "msg": "session not found"}
* if session hasn't active user, shouldn't happen't at all, login-server should be checked if happen
* {"state": "code error", "msg":"user is zero"}
* if transaction type not known
* {"state": "error", "msg":"transaction_type unknown"}
* if receiver wasn't known to Login-Server
* {"state": "not found", "msg":"receiver not found"}
* if receiver account disabled, and therefor cannto receive any coins
* {"state": "disabled", "msg":"receiver is disabled"}
* if transaction was okay and will be further proccessed
* {"state":"success"}
*/
$answear_data = $requestAnswear['data'];
return $this->returnJson($answear_data);
}
}
public function createCoins()
{
/*
* "session_id" : -127182,
* "email": "max.musterman@gmail.de",
* "amount": 10000000,
* "target_date":"2021-02-19T13:25:36+00:00",
* "memo":"AGE",
* "auto_sign": true
*/
if(!$this->request->is('post')) {
return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
}
$data = $this->request->input('json_decode');
$params = [];
$result = $this->parseParameterForCreateTransaction($params, $data);
if($result !== true) {
return $this->returnJson($result);
}
$required_fields = $this->checkAndCopyRequiredFields(['target_date'], $params, $data);
if($required_fields !== true) {
return $this->returnJson($required_fields);
}
$params['transaction_type'] = 'creation';
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode($params), '/createTransaction');
if('success' == $requestAnswear['state'] && 'success' == $requestAnswear['data']['state']) {
$session = $this->getRequest()->getSession();
$pendingTransactionCount = $session->read('Transactions.pending');
if($pendingTransactionCount == null) {
$pendingTransactionCount = 1;
} else {
$pendingTransactionCount++;
}
$session->write('Transactions.pending', $pendingTransactionCount);
//echo "pending: " . $pendingTransactionCount;
return $this->returnJson(['state' => 'success']);
} else {
/*
* if request contain unknown parameter format, shouldn't happen't at all
* {"state": "error", "msg": "parameter format unknown"}
* if json parsing failed
* {"state": "error", "msg": "json exception", "details":"exception text"}
* if session_id is zero or not set
* {"state": "error", "msg": "session_id invalid"}
* if session id wasn't found on login server, if server was restartet or user logged out (also per timeout, default: 15 minutes)
* {"state": "error", "msg": "session not found"}
* if session hasn't active user, shouldn't happen't at all, login-server should be checked if happen
* {"state": "code error", "msg":"user is zero"}
* if transaction type not known
* {"state": "error", "msg":"transaction_type unknown"}
* if receiver wasn't known to Login-Server
* {"state": "not found", "msg":"receiver not found"}
* if receiver account disabled, and therefor cannto receive any coins
* {"state": "disabled", "msg":"receiver is disabled"}
* if transaction was okay and will be further proccessed
* {"state":"success"}
*/
$answear_data = $requestAnswear['data'];
return $this->returnJson($answear_data);
}
}
public function getBalance($session_id = 0)
{
$this->viewBuilder()->setLayout('ajax');
$login_result = $this->requestLogin($session_id, false);
if($login_result !== true) {
$this->set('body', $login_result);
return;
}
$session = $this->getRequest()->getSession();
$user = $session->read('StateUser');
$state_balances_table = TableRegistry::getTableLocator()->get('StateBalances');
$state_balances_table->updateBalances($user['id']);
$state_balance = $state_balances_table->find()->where(['state_user_id' => $user['id']])->first();
$now = new FrozenTime();
if(!$state_balance) {
$body = [
'state' => 'success',
'balance' => 0,
'decay' => 0
];
} else {
$body = [
'state' => 'success',
'balance' => $state_balance->amount,
'decay' => $state_balance->partDecay($now),
];
}
$body['decay_date'] = $now;
$this->set('body', $body);
}
public function listTransactions($page = 1, $count = 25, $orderDirection = 'ASC', $session_id = 0)
{
$this->viewBuilder()->setLayout('ajax');
$startTime = microtime(true);
$login_result = $this->requestLogin($session_id, false);
if($login_result !== true) {
return $this->returnJson($login_result);
}
$session = $this->getRequest()->getSession();
$user = $session->read('StateUser');
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
$stateBalancesTable->updateBalances($user['id']);
$gdtSum = 0;
$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
$gdtSum = intval($gdtEntries['data']['sum']);
} else {
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id'] ? $user['id'] : 0);
}
//echo "count: $count, page: $page<br>";
$limit = $count;
$offset = 0;
$skip_first_transaction = false;
if($page > 1) {
$offset = (( $page - 1 ) * $count) - 1;
$limit++;
}
if($offset && $orderDirection == 'ASC') {
$offset--;
}
//echo "limit: $limit, offset: $offset, skip first transaction: $skip_first_transaction<br>";
$stateUserTransactionsQuery = $stateUserTransactionsTable
->find()
->where(['state_user_id' => $user['id']])
->order(['balance_date' => $orderDirection])
->contain([])
->limit($limit)
//->page($page)
->offset($offset)
;
$state_user_transactions_count = $stateUserTransactionsQuery->count();
if($state_user_transactions_count > $offset + $limit) {
$skip_first_transaction = true;
}
$decay = true;
if($page > 1) {
$decay = false;
}
$transactions = [];
$transactions_from_db = $stateUserTransactionsQuery->toArray();
if(count($transactions_from_db)) {
if($orderDirection == 'DESC') {
$transactions_from_db = array_reverse($transactions_from_db);
}
$transactions = $transactionsTable->listTransactionsHumanReadable($transactions_from_db, $user, $decay, $skip_first_transaction);
//echo "transactions count: " . count($transactions) . "<br>";
if($orderDirection == 'DESC') {
$transactions = array_reverse($transactions);
}
}
$state_balance = $stateBalancesTable->find()->where(['state_user_id' => $user['id']])->first();
$body = [
'state' => 'success',
'transactions' => $transactions,
'transactionExecutingCount' => $session->read('Transactions.executing'),
'count' => $state_user_transactions_count,
'gdtSum' => $gdtSum,
'timeUsed' => microtime(true) - $startTime
];
$now = new FrozenTime();
$body['decay_date'] = $now;
if(!$state_balance) {
$body['balance'] = 0.0;
$body['decay'] = 0.0;
} else {
$body['balance'] = $state_balance->amount;
$body['decay'] = $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now);
}
$this->set('body', $body);
}
public function listGDTTransactions($page = 1, $count = 25, $orderDirection = 'ASC', $session_id = 0)
{
$timeBegin = microtime(true);
$this->viewBuilder()->setLayout('ajax');
$login_result = $this->requestLogin($session_id, false);
if($login_result !== true) {
return $this->returnJson($login_result);
}
$session = $this->getRequest()->getSession();
$user = $session->read('StateUser');
if(!$user) {
return $this->returnJson(['state' => 'error', 'msg' => 'user not found', 'details' => 'exist a valid session cookie?']);
}
$gdtEntries = $this->JsonRequestClient->sendRequestGDT([
'email' => $user['email'],
'page' => $page,
'count' => $count,
'orderDirection' => $orderDirection
], 'GdtEntries' . DS . 'listPerEmailApi');
if('success' == $gdtEntries['state']) {
$timeEnd = microtime(true);
$gdtEntries['data']['timeUsed'] = $timeEnd - $timeBegin;
return $this->returnJson($gdtEntries['data']);
} else {
if($user) {
$this->addAdminError('StateBalancesController', 'ajaxGdtOverview', $gdtEntries, $user['id']);
} else {
$this->addAdminError('StateBalancesController', 'ajaxGdtOverview', $gdtEntries, 0);
}
}
return $this->returnJson(['state' => 'error', 'msg' => 'error by requesting gdt server', 'details' => $gdtEntries]);
}
public function getDecayStartBlock()
{
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
$decayStartBlock = $transactionsTable->find()->where(['transaction_type_id' => 9]);
if(!$decayStartBlock->count()) {
return $this->returnJson(['state' => 'error', 'msg' => 'not found']);
}
return $this->returnJson(['state' => 'success', 'decay_start' => $decayStartBlock->first()->received]);
}
private function acquireAccessToken($session_id)
{
}
}

View File

@ -1,106 +0,0 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* BlockchainTypes Controller
*
* @property \App\Model\Table\BlockchainTypesTable $BlockchainTypes
*
* @method \App\Model\Entity\BlockchainType[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class BlockchainTypesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$blockchainTypes = $this->paginate($this->BlockchainTypes);
$this->set(compact('blockchainTypes'));
}
/**
* View method
*
* @param string|null $id Blockchain Type id.
* @return \Cake\Http\Response|null
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$blockchainType = $this->BlockchainTypes->get($id, [
'contain' => [],
]);
$this->set('blockchainType', $blockchainType);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$blockchainType = $this->BlockchainTypes->newEntity();
if ($this->request->is('post')) {
$blockchainType = $this->BlockchainTypes->patchEntity($blockchainType, $this->request->getData());
if ($this->BlockchainTypes->save($blockchainType)) {
$this->Flash->success(__('The blockchain type has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The blockchain type could not be saved. Please, try again.'));
}
$this->set(compact('blockchainType'));
}
/**
* Edit method
*
* @param string|null $id Blockchain Type id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
$blockchainType = $this->BlockchainTypes->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$blockchainType = $this->BlockchainTypes->patchEntity($blockchainType, $this->request->getData());
if ($this->BlockchainTypes->save($blockchainType)) {
$this->Flash->success(__('The blockchain type has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The blockchain type could not be saved. Please, try again.'));
}
$this->set(compact('blockchainType'));
}
/**
* Delete method
*
* @param string|null $id Blockchain Type id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$blockchainType = $this->BlockchainTypes->get($id);
if ($this->BlockchainTypes->delete($blockchainType)) {
$this->Flash->success(__('The blockchain type has been deleted.'));
} else {
$this->Flash->error(__('The blockchain type could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -1,106 +0,0 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* CommunityProfiles Controller
*
* @property \App\Model\Table\CommunityProfilesTable $CommunityProfiles
*
* @method \App\Model\Entity\CommunityProfile[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class CommunityProfilesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$communityProfiles = $this->paginate($this->CommunityProfiles);
$this->set(compact('communityProfiles'));
}
/**
* View method
*
* @param string|null $id Community Profile id.
* @return \Cake\Http\Response|null
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$communityProfile = $this->CommunityProfiles->get($id, [
'contain' => [],
]);
$this->set('communityProfile', $communityProfile);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$communityProfile = $this->CommunityProfiles->newEntity();
if ($this->request->is('post')) {
$communityProfile = $this->CommunityProfiles->patchEntity($communityProfile, $this->request->getData());
if ($this->CommunityProfiles->save($communityProfile)) {
$this->Flash->success(__('The community profile has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The community profile could not be saved. Please, try again.'));
}
$this->set(compact('communityProfile'));
}
/**
* Edit method
*
* @param string|null $id Community Profile id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
$communityProfile = $this->CommunityProfiles->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$communityProfile = $this->CommunityProfiles->patchEntity($communityProfile, $this->request->getData());
if ($this->CommunityProfiles->save($communityProfile)) {
$this->Flash->success(__('The community profile has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The community profile could not be saved. Please, try again.'));
}
$this->set(compact('communityProfile'));
}
/**
* Delete method
*
* @param string|null $id Community Profile id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$communityProfile = $this->CommunityProfiles->get($id);
if ($this->CommunityProfiles->delete($communityProfile)) {
$this->Flash->success(__('The community profile has been deleted.'));
} else {
$this->Flash->error(__('The community profile could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -1,33 +0,0 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller\Component;
use Cake\Controller\Component;
class GradidoNumberComponent extends Component
{
// input can be from 0,01 or 0.01 up to big number be anything
public function parseInputNumberToCentNumber($inputNumber)
{
//$filteredInputNumber = preg_replace('/,/', '.', $inputNumber);
$parts = preg_split('/(,|\.)/', (string)$inputNumber);
$result = intval($parts[0]) * 10000;
if(count($parts) == 2) {
$result += intval($parts[1]) * 100;
}
return $result;
}
public function centToPrint($centAmount)
{
}
}

View File

@ -1,184 +0,0 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller\Component;
use App\Model\Validation\GenericValidation;
use Cake\Controller\Component;
use Cake\Http\Client;
use Cake\Core\Configure;
class JsonRequestClientComponent extends Component
{
public function sendTransaction($session_id, $base64Message, $user_balance = 0, $auto_sign = false, $blockchain_type = 'mysql') {
if(!is_numeric($session_id)) {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'session_id isn\'t numeric'];
}
if(!is_numeric($user_balance) || intval($user_balance) < 0) {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'user_balance invalid'];
}
if(is_array($base64Message)) {
foreach($base64Message as $singleMessage) {
if(!$this->is_base64($singleMessage)) {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'at least one base64Message contain invalid base64 characters'];
}
}
} else if(!$this->is_base64($base64Message)) {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'base64Message contain invalid base64 characters'];
}
return $this->sendRequest(json_encode([
'session_id' => $session_id,
'transaction_base64' => $base64Message,
'balance' => $user_balance,
'auto_sign' => $auto_sign,
'blockchain_type' => $this->blockchainType
]), '/checkTransaction');
}
public function findePublicKeyForEmailHash($emailHash) {
//'ask' = ['account_publickey' => '<email_blake2b_base64>']
$results = $this->sendRequestLoginServerNeighbors(json_encode(['ask' => ['account_publickey' => $emailHash]]), 'search');
}
public function getRunningUserTasks($email)
{
if($email == "") {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'email is empty'];
}
if(!GenericValidation::email($email, [])) {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'email is invalid'];
}
return $this->sendRequest(json_encode([
'email' => $email
]), '/getRunningUserTasks');
}
public function getUsers($session_id, $searchString, $accountState)
{
if($searchString == "") {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'search string is empty'];
}
if(!is_numeric($session_id)) {
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'session_id isn\'t numeric'];
}
return $this->sendRequest(json_encode([
'session_id' => $session_id,
'search' => $searchString,
'account_state' => $accountState,
]), '/getUsers');
}
public function sendRequest($transactionBody, $url_last_part) {
$http = new Client();
$response = $http->post($this->getLoginServerUrl() . $url_last_part, $transactionBody, ['type' => 'json']);
$responseStatus = $response->getStatusCode();
if($responseStatus != 200) {
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus];
}
//$responseType = $response->getType();
//if($responseType != 'application/json') {
// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType];
// }
$json = $response->getJson();
if($json == null) {
//$responseType = $response->getType();
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
}
return ['state' => 'success', 'data' => $json];
}
public function sendRequestGDT($transactionBody, $url) {
$http = new Client();
$gdtServerHost = $this->getGDTServerUrl();
if(!$gdtServerHost) {
return ['state' => 'warning', 'msg' => 'gdt server not configured'];
}
$fullUrl = $gdtServerHost . DS . $url;
$response = $http->post($this->getGDTServerUrl() . DS . $url, $transactionBody, ['type' => 'json']);
$responseStatus = $response->getStatusCode();
if($responseStatus != 200) {
return [
'state' => 'error',
'type' => 'request error',
'msg' => 'server response status code isn\'t 200',
'details' => $responseStatus,
'fullUrl' => $fullUrl
];
}
//$responseType = $response->getType();
//if($responseType != 'application/json') {
// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType];
// }
$json = $response->getJson();
if($json == null) {
//$responseType = $response->getType();
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
}
return ['state' => 'success', 'data' => $json];
}
public function sendRequestLoginServerNeighbors($transactionBody, $url) {
$http = new Client();
if(!Configure::check('NeighborLoginServers')) {
return ['state' => 'warning', 'msg' => 'no neighbor server configured'];
}
$nServers = Configure::read('NeighborLoginServers');
$results = ['errors' => [], 'data' => []];
foreach($nServers as $nServer) {
$full_url = $nServer['host'] . ':' . $nServer['port'] . '/' . $url;
$response = $http->post($full_url, $transactionBody, ['type' => 'json']);
$responseStatus = $response->getStatusCode();
if($responseStatus != 200) {
$results['errors'][] = [
'state' => 'error',
'type' => 'request error',
'msg' => 'server response status code isn\'t 200',
'details' => $responseStatus,
'fullUrl' => $full_url
];
continue;
}
$json = $response->getJson();
if($json == null) {
//$responseType = $response->getType();
$results['errors'][] = ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
continue;
}
$results['data'][] = $json;
}
return $results;
}
static public function getLoginServerUrl()
{
$loginServer = Configure::read('LoginServer');
return $loginServer['host'] . ':' . $loginServer['port'];
}
static public function getGDTServerUrl()
{
$gdtServer = Configure::read('GDTServer');
if(isset($gdtServer['host'])) {
return $gdtServer['host'];
}
return false;
}
static public function is_base64($s)
{
return (bool) preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $s);
}
}

View File

@ -1,83 +0,0 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Http\Client;
use Cake\Core\Configure;
use Datto\JsonRpc\Client as JsonRpcClient;
//App\Controller\Component\ComponentRegistry
class JsonRpcRequestClientComponent extends Component
{
var $rpcClient = null;
public function __construct($registry, array $config = array()) {
parent::__construct($registry, $config);
$this->rpcClient = new JsonRpcClient();
}
// @param id: if id = 0 call rand for it
public function request($method, $params = [], $id = 0)
{
if(0 == $id) {
$id = random_int(1, 12000);
}
$this->rpcClient->query($id, $method, $params);
$message = $this->rpcClient->encode();
return $this->sendRequest($message);
// message: {"jsonrpc":"2.0","method":"add","params":[1,2],"id":1}
}
public function sendRequest($message) {
$http = new Client();
try {
$url = $this->pickGradidoNodeUrl();
if(is_array($url)) {
return $url;
}
$response = $http->post($url, $message, ['type' => 'json']);
} catch(Exception $e) {
return ['state' => 'error', 'type' => 'http exception', 'details' => $e->getMessage()];
}
$responseStatus = $response->getStatusCode();
if($responseStatus != 200) {
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus];
}
//$responseType = $response->getType();
//if($responseType != 'application/json') {
// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType];
// }
$json = $response->getJson();
if($json == null) {
//$responseType = $response->getType();
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
}
return $json['result'];
//return ['state' => 'success', 'data' => $json];
}
static public function pickGradidoNodeUrl()
{
$gradidoNodes = Configure::read('GradidoBlockchain.nodes');
if(count($gradidoNodes) == 0) {
return ['state' => 'error', 'msg' => 'no gradido nodes in config'];
}
$i = rand(0, count($gradidoNodes)-1);
return $gradidoNodes[$i]['host'] . ':' . $gradidoNodes[$i]['port'];
}
}

View File

@ -1,78 +0,0 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
//use Cake\Routing\Router;
use Cake\ORM\TableRegistry;
use Model\Navigation\NaviHierarchy;
use Model\Navigation\NaviHierarchyEntry;
/**
* StateUsers Controller
*
* @property \App\Model\Table\StateUsersTable $StateUsers
*
* @method \App\Model\Entity\StateUser[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class DashboardController extends AppController
{
public function initialize()
{
parent::initialize();
//$this->Auth->allow(['add', 'edit']);
$this->Auth->allow(['index', 'errorHttpRequest']);
$this->set(
'naviHierarchy',
(new NaviHierarchy())->
add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', true))
);
}
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$startTime = microtime(true);
$this->viewBuilder()->setLayout('frontend');
$session = $this->getRequest()->getSession();
$result = $this->requestLogin();
if($result !== true) {
return $result;
}
$user = $session->read('StateUser');
$serverUser = $this->Auth->user('id');
if($serverUser) {
$adminErrorsTable = TableRegistry::getTableLocator()->get('AdminErrors');
$adminErrorCount = $adminErrorsTable->find('all')->count();
$this->set('adminErrorCount', $adminErrorCount);
}
$this->set('user', $user);
$this->set('serverUser', $serverUser);
$this->set('timeUsed', microtime(true) - $startTime);
}
public function serverIndex()
{
$startTime = microtime(true);
$this->viewBuilder()->setLayout('frontend');
$adminErrorsTable = TableRegistry::getTableLocator()->get('AdminErrors');
$adminErrorCount = $adminErrorsTable->find('all')->count();
$this->set('adminErrorCount', $adminErrorCount);
$this->set('timeUsed', microtime(true) - $startTime);
}
public function errorHttpRequest()
{
$startTime = microtime(true);
$this->viewBuilder()->setLayout('frontend');
$this->set('timeUsed', microtime(true) - $startTime);
}
}

View File

@ -1,165 +0,0 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
use Cake\Datasource\ConnectionManager;
use Cake\I18n\Time;
//use Cake\I18n\Date;
use Cake\ORM\TableRegistry;
/**
* ElopageBuys Controller
*
* @property \App\Model\Table\ElopageBuysTable $ElopageBuys
*
* @method \App\Model\Entity\ElopageBuy[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class ElopageBuysController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$this->paginate = [
'contain' => false,
];
$elopageBuys = $this->paginate($this->ElopageBuys);
$this->set(compact('elopageBuys'));
}
public function statistics()
{
$this->viewBuilder()->setLayout('frontend');
$connection = ConnectionManager::get('loginServer');
$dates = $connection->execute('SELECT success_date FROM elopage_buys group by CAST(success_date as DATE)')->fetchAll('assoc');
$datesTree = [];
foreach($dates as $i => $date) {
$date = new Time($date['success_date']);
if(!isset($datesTree[$date->year])) {
$datesTree[$date->year] = [];
}
if(!isset($datesTree[$date->year][$date->month])) {
$datesTree[$date->year][$date->month] = true;
}
}
//var_dump($datesTree);
$now = Time::now();
$lastDay = Time::now();
$lastDay->day = 1;
$now->day = 1;
$lastDay->setTime(0,0,0,0);
$now->setTime(0,0,0,0);
// only for test
$now->month = 11;
$lastDay->month = 11;
$now->year = 2019;
$lastDay->year = 2019;
// var_dump($now);
$lastDay = $lastDay->addMonth(1);
$sortDate = $this->getStartEndForMonth(11, 2019);
$elopageBuys = $this->ElopageBuys
->find('all')
->where(['success_date >=' => $sortDate[0], 'success_date <' => $sortDate[1]]);
$users = [];
foreach($elopageBuys as $elopageEntry) {
array_push($users, $elopageEntry->payer_email);
}
$unique_users = array_unique($users);
$userTable = TableRegistry::getTableLocator()->get('Users');
$users = $userTable->find('all')
->where(['created >=' => $sortDate[0], 'created <' => $sortDate[1]]);
$this->set(compact('elopageBuys', 'users'));
}
/**
* View method
*
* @param string|null $id Elopage Buy id.
* @return \Cake\Http\Response|null
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$elopageBuy = $this->ElopageBuys->get($id, [
'contain' => false,
]);
$this->set('elopageBuy', $elopageBuy);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$elopageBuy = $this->ElopageBuys->newEntity();
if ($this->request->is('post')) {
$elopageBuy = $this->ElopageBuys->patchEntity($elopageBuy, $this->request->getData());
if ($this->ElopageBuys->save($elopageBuy)) {
$this->Flash->success(__('The elopage buy has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The elopage buy could not be saved. Please, try again.'));
}
$this->set(compact('elopageBuy'));
}
/**
* Edit method
*
* @param string|null $id Elopage Buy id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
$elopageBuy = $this->ElopageBuys->get($id, [
'contain' => false,
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$elopageBuy = $this->ElopageBuys->patchEntity($elopageBuy, $this->request->getData());
if ($this->ElopageBuys->save($elopageBuy)) {
$this->Flash->success(__('The elopage buy has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The elopage buy could not be saved. Please, try again.'));
}
$this->set(compact('elopageBuy'));
}
/**
* Delete method
*
* @param string|null $id Elopage Buy id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$elopageBuy = $this->ElopageBuys->get($id);
if ($this->ElopageBuys->delete($elopageBuy)) {
$this->Flash->success(__('The elopage buy has been deleted.'));
} else {
$this->Flash->error(__('The elopage buy could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -1,51 +0,0 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller;
use App\Controller\AppController;
class ElopageWebhookController extends AppController
{
public function initialize()
{
parent::initialize();
$this->Auth->allow(['put']);
}
public function put()
{
$this->autoRender = false;
$data = $this->request->getData();
$response = $this->response->withType('text/plain');
$dataString = http_build_query($data);
//$this->recursiveArrayToString($data, $dataString);
// %5B => [
// %5D => ]
$dataString = preg_replace(['/\%5B/', '/\%5D/'], ['[', ']'], $dataString);
//var_dump($dataString);
//2020-02-27T13:52:32+01:00
$dateString = date('c');
$fh = fopen('/etc/grd_login/php_elopage_requests.txt', 'a');
if($fh === FALSE) {
return $response->withStringBody('400 ERROR');
}
fwrite($fh, $dateString);
fwrite($fh, "\n");
fwrite($fh, $dataString);
fwrite($fh, "\n");
fclose($fh);
return $response->withStringBody('200 OK');
}
}

View File

@ -1,70 +0,0 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.3.4
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Controller;
use Cake\Event\Event;
/**
* Error Handling Controller
*
* Controller used by ExceptionRenderer to render error responses.
*/
class ErrorController extends AppController
{
/**
* Initialization hook method.
*
* @return void
*/
public function initialize()
{
$this->loadComponent('RequestHandler', [
'enableBeforeRedirect' => false,
]);
}
/**
* beforeFilter callback.
*
* @param \Cake\Event\Event $event Event.
* @return \Cake\Http\Response|null|void
*/
public function beforeFilter(Event $event)
{
}
/**
* beforeRender callback.
*
* @param \Cake\Event\Event $event Event.
* @return \Cake\Http\Response|null|void
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->RequestHandler->renderAs($this, 'json');
$this->viewBuilder()->setTemplatePath('Error');
}
/**
* afterFilter callback.
*
* @param \Cake\Event\Event $event Event.
* @return \Cake\Http\Response|null|void
*/
public function afterFilter(Event $event)
{
}
}

Some files were not shown because too many files have changed in this diff Show More