From b493fd42311be96e669419f9329ef2a0d1f262ee Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 16 Jun 2022 09:21:37 +0200 Subject: [PATCH 01/23] migration to save contribution link on registration --- backend/src/config/index.ts | 2 +- .../User.ts | 79 +++++++++++++++++++ database/entity/User.ts | 2 +- .../0040-add_contribution_link_id_to_user.ts | 14 ++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 database/entity/0040-add_contribution_link_id_to_user/User.ts create mode 100644 database/migrations/0040-add_contribution_link_id_to_user.ts diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 2a99fd3c0..4e6dd8099 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0039-contributions_table', + DB_VERSION: '0040-add_contribution_link_id_to_user', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/database/entity/0040-add_contribution_link_id_to_user/User.ts b/database/entity/0040-add_contribution_link_id_to_user/User.ts new file mode 100644 index 000000000..9bf76e5f5 --- /dev/null +++ b/database/entity/0040-add_contribution_link_id_to_user/User.ts @@ -0,0 +1,79 @@ +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn } from 'typeorm' + +@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class User extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ name: 'public_key', type: 'binary', length: 32, default: null, nullable: true }) + pubKey: Buffer + + @Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true }) + privKey: Buffer + + @Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' }) + email: string + + @Column({ + name: 'first_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + firstName: string + + @Column({ + name: 'last_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + lastName: string + + @DeleteDateColumn() + deletedAt: Date | null + + @Column({ type: 'bigint', default: 0, unsigned: true }) + password: BigInt + + @Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true }) + emailHash: Buffer + + @Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + createdAt: Date + + @Column({ name: 'email_checked', type: 'bool', nullable: false, default: false }) + emailChecked: boolean + + @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false }) + language: string + + @Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null }) + isAdmin: Date | null + + @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null }) + referrerId?: number | null + + @Column({ + name: 'contribution_link_id', + type: 'int', + unsigned: true, + nullable: true, + default: null, + }) + contributionLinkId?: number | null + + @Column({ name: 'publisher_id', default: 0 }) + publisherId: number + + @Column({ + type: 'text', + name: 'passphrase', + collation: 'utf8mb4_unicode_ci', + nullable: true, + default: null, + }) + passphrase: string +} diff --git a/database/entity/User.ts b/database/entity/User.ts index 2d434799e..99b8c8ca9 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0037-drop_user_setting_table/User' +export { User } from './0040-add_contribution_link_id_to_user/User' diff --git a/database/migrations/0040-add_contribution_link_id_to_user.ts b/database/migrations/0040-add_contribution_link_id_to_user.ts new file mode 100644 index 000000000..ebe7896df --- /dev/null +++ b/database/migrations/0040-add_contribution_link_id_to_user.ts @@ -0,0 +1,14 @@ +/* MIGRATION TO ADD contribution_link_id FIELD TO users */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'ALTER TABLE `users` ADD COLUMN `contribution_link_id` int UNSIGNED DEFAULT NULL AFTER `referrer_id`;', + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('ALTER TABLE `users` DROP COLUMN `contribution_link_id`;') +} From 1ba7e861731cabc3f877e93e58b8a6a89d1577d6 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 16 Jun 2022 10:21:59 +0200 Subject: [PATCH 02/23] changed redeem for contribution link and transaction link --- .../LinkInformations/RedeemInformation.vue | 18 +++++++++++++++--- .../LinkInformations/RedeemLoggedOut.vue | 7 +++---- frontend/src/locales/de.json | 3 +++ frontend/src/locales/en.json | 3 +++ frontend/src/pages/TransactionLink.vue | 6 ++++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/LinkInformations/RedeemInformation.vue b/frontend/src/components/LinkInformations/RedeemInformation.vue index bdc17db9a..752cc9596 100644 --- a/frontend/src/components/LinkInformations/RedeemInformation.vue +++ b/frontend/src/components/LinkInformations/RedeemInformation.vue @@ -1,8 +1,12 @@ diff --git a/frontend/src/components/LinkInformations/RedeemLoggedOut.vue b/frontend/src/components/LinkInformations/RedeemLoggedOut.vue index a5cb97955..982bfdf08 100644 --- a/frontend/src/components/LinkInformations/RedeemLoggedOut.vue +++ b/frontend/src/components/LinkInformations/RedeemLoggedOut.vue @@ -1,6 +1,6 @@