From 2c88bc03838fa6810edc7fcd41f6e6e133b71d71 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Feb 2022 07:32:39 +0100 Subject: [PATCH 01/17] remove query for checkEmail as it is included in the user model now --- backend/src/graphql/resolver/AdminResolver.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 54fe9335e..80345fb49 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -22,7 +22,6 @@ import { BalanceRepository } from '../../typeorm/repository/Balance' import { calculateDecay } from '../../util/decay' import { AdminPendingCreation } from '@entity/AdminPendingCreation' import { hasElopageBuys } from '../../util/hasElopageBuys' -import { User as dbUser } from '@entity/User' @Resolver() export class AdminResolver { @@ -41,7 +40,7 @@ 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) return adminUser }), @@ -61,8 +60,7 @@ export class AdminResolver { ): Promise { 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) @@ -374,8 +372,3 @@ function isCreationValid(creations: number[], amount: number, creationDate: Date } return true } - -async function hasActivatedEmail(email: string): Promise { - const user = await dbUser.findOne({ email }) - return user ? user.emailChecked : false -} From b3be4f664a8a59530bdcf89dd6184f852aba3cbf Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Feb 2022 08:05:25 +0100 Subject: [PATCH 02/17] add date of last email confirmation send to admin user --- backend/src/graphql/model/UserAdmin.ts | 3 +++ backend/src/graphql/resolver/AdminResolver.ts | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/backend/src/graphql/model/UserAdmin.ts b/backend/src/graphql/model/UserAdmin.ts index 27dfe96f1..11cf384b3 100644 --- a/backend/src/graphql/model/UserAdmin.ts +++ b/backend/src/graphql/model/UserAdmin.ts @@ -22,6 +22,9 @@ export class UserAdmin { @Field(() => Boolean) hasElopage: boolean + + @Field(() => String, { nullable: true }) + emailConfirmationSend?: string } @ObjectType() diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 80345fb49..e89f20ba6 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -22,6 +22,9 @@ import { BalanceRepository } from '../../typeorm/repository/Balance' import { calculateDecay } from '../../util/decay' import { AdminPendingCreation } from '@entity/AdminPendingCreation' import { hasElopageBuys } from '../../util/hasElopageBuys' +import { LoginEmailOptIn } from '@entity/LoginEmailOptIn' + +const EMAIL_OPT_IN_REGISTER = 1 @Resolver() export class AdminResolver { @@ -42,6 +45,13 @@ export class AdminResolver { adminUser.creation = await getUserCreations(user.id) adminUser.emailChecked = user.emailChecked adminUser.hasElopage = await hasElopageBuys(user.email) + if (!user.emailChecked) { + const emailOptIn = await LoginEmailOptIn.findOne({ + userId: user.id, + emailOptInTypeId: EMAIL_OPT_IN_REGISTER, + }) + if (emailOptIn) adminUser.emailConfirmationSend = emailOptIn.updatedAt.toISOString() + } return adminUser }), ) From 9f51438b610731d233a88ab601eeb059fa721eb8 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Feb 2022 08:06:19 +0100 Subject: [PATCH 03/17] fix English time --- admin/src/locales/de.json | 2 +- admin/src/locales/en.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 327cfd302..733c30572 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -71,7 +71,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" } diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 3f12f10a8..a4dc9fd9b 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -70,8 +70,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" } From 26e2ba448a193cf378239be3e996de946f69632a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Feb 2022 08:07:15 +0100 Subject: [PATCH 04/17] long datetime format with long weekday and month --- admin/src/i18n.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/src/i18n.js b/admin/src/i18n.js index 6291a9c6c..b2bb08074 100644 --- a/admin/src/i18n.js +++ b/admin/src/i18n.js @@ -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', }, From 7e54251f71ea13dd9df3be4dfa978b9497e73b01 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 10 Feb 2022 08:08:48 +0100 Subject: [PATCH 05/17] display coorect date when the last confirmation email was sent --- admin/src/components/ConfirmRegisterMailFormular.vue | 2 +- admin/src/components/UserTable.vue | 6 +++++- admin/src/graphql/searchUsers.js | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/src/components/ConfirmRegisterMailFormular.vue b/admin/src/components/ConfirmRegisterMailFormular.vue index 635b80939..752f4b2cf 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.vue +++ b/admin/src/components/ConfirmRegisterMailFormular.vue @@ -1,7 +1,7 @@