From 433000e536ef20a83bdfe4515d1577f40eb77342 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 6 Mar 2022 10:50:14 +0100 Subject: [PATCH 1/3] allow sending to user without transactions --- backend/src/graphql/resolver/TransactionResolver.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 14b80a5ea..73d9b36be 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -192,14 +192,11 @@ export class TransactionResolver { transactionReceive.linkedUserId = senderUser.id transactionReceive.amount = amount const receiveBalance = await calculateBalance(recipientUser.id, amount, receivedCallDate) - if (!receiveBalance) { - throw new Error('Sender user account corrupted') - } - transactionReceive.balance = receiveBalance.balance + transactionReceive.balance = receiveBalance ? receiveBalance.balance : amount transactionReceive.balanceDate = receivedCallDate - transactionReceive.decay = receiveBalance.decay.decay - transactionReceive.decayStart = receiveBalance.decay.start - transactionReceive.previous = receiveBalance.lastTransactionId + transactionReceive.decay = receiveBalance ? receiveBalance.decay.decay : new Decimal(0) + transactionReceive.decayStart = receiveBalance ? receiveBalance.decay.start : null + transactionReceive.previous = receiveBalance ? receiveBalance.lastTransactionId : null transactionReceive.linkedTransactionId = transactionSend.id await queryRunner.manager.insert(dbTransaction, transactionReceive) From f1c4e847fea5e33997adcf5e5f5f709a0b88c888 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 6 Mar 2022 10:52:13 +0100 Subject: [PATCH 2/3] fix previous database field definition --- database/entity/0029-clean_transaction_table/Transaction.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/entity/0029-clean_transaction_table/Transaction.ts b/database/entity/0029-clean_transaction_table/Transaction.ts index 7989e918a..5931c153f 100644 --- a/database/entity/0029-clean_transaction_table/Transaction.ts +++ b/database/entity/0029-clean_transaction_table/Transaction.ts @@ -10,8 +10,8 @@ export class Transaction extends BaseEntity { @Column({ name: 'user_id', unsigned: true, nullable: false }) userId: number - @Column({ unsigned: true, nullable: true, default: null }) - previous: number + @Column({ type: 'int', unsigned: true, nullable: true, default: null }) + previous: number | null @Column({ name: 'type_id', unsigned: true, nullable: false }) typeId: number From cc596df22a0b26f2dafea7304c56e89b5c360bcb Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 7 Mar 2022 13:31:33 +0100 Subject: [PATCH 3/3] validate valitity of userpassword when updating it via updateUserInfos --- backend/src/graphql/resolver/UserResolver.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 6b1e7162e..dcb3e03b6 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -592,6 +592,13 @@ export class UserResolver { } if (password && passwordNew) { + // Validate Password + if (!isPassword(passwordNew)) { + throw new Error( + 'Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character!', + ) + } + // TODO: This had some error cases defined - like missing private key. This is no longer checked. const oldPasswordHash = SecretKeyCryptographyCreateKey(userEntity.email, password) if (BigInt(userEntity.password.toString()) !== oldPasswordHash[0].readBigUInt64LE()) {