mirror of
https://github.com/IT4Change/gradido.git
synced 2026-04-04 16:45:27 +00:00
Merge pull request #1448 from gradido/admin-email-confirmation
fix: Admin Email Confirmation Date and Time
This commit is contained in:
commit
a503a4d456
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="component-confirm-register-mail">
|
<div class="component-confirm-register-mail">
|
||||||
<div class="shadow p-3 mb-5 bg-white rounded">
|
<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>
|
<div v-else>
|
||||||
{{ $t('unregister_mail.text_false', { date: dateLastSend, mail: email }) }}
|
{{ $t('unregister_mail.text_false', { date: dateLastSend, mail: email }) }}
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,11 @@
|
|||||||
<confirm-register-mail-formular
|
<confirm-register-mail-formular
|
||||||
:checked="row.item.emailChecked"
|
:checked="row.item.emailChecked"
|
||||||
:email="row.item.email"
|
:email="row.item.email"
|
||||||
:dateLastSend="$d(new Date(), 'long')"
|
:dateLastSend="
|
||||||
|
row.item.emailConfirmationSend
|
||||||
|
? $d(new Date(row.item.emailConfirmationSend), 'long')
|
||||||
|
: ''
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #show-transaction-list>
|
<template #show-transaction-list>
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export const searchUsers = gql`
|
|||||||
creation
|
creation
|
||||||
emailChecked
|
emailChecked
|
||||||
hasElopage
|
hasElopage
|
||||||
|
emailConfirmationSend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,9 +54,9 @@ const dateTimeFormats = {
|
|||||||
},
|
},
|
||||||
long: {
|
long: {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'short',
|
month: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
weekday: 'short',
|
weekday: 'long',
|
||||||
hour: 'numeric',
|
hour: 'numeric',
|
||||||
minute: 'numeric',
|
minute: 'numeric',
|
||||||
},
|
},
|
||||||
@ -78,9 +78,9 @@ const dateTimeFormats = {
|
|||||||
},
|
},
|
||||||
long: {
|
long: {
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
month: 'short',
|
month: 'long',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
weekday: 'short',
|
weekday: 'long',
|
||||||
hour: 'numeric',
|
hour: 'numeric',
|
||||||
minute: 'numeric',
|
minute: 'numeric',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -77,7 +77,7 @@
|
|||||||
"info": "Email bestätigen, wiederholt senden an:",
|
"info": "Email bestätigen, wiederholt senden an:",
|
||||||
"success": "Erfolgreiches Senden des Bestätigungs-Links an die E-Mail des Nutzers! ({email})",
|
"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_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"
|
"user_search": "Nutzer-Suche"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,8 +76,8 @@
|
|||||||
"error": "Error sending the confirmation link to the user: {message}",
|
"error": "Error sending the confirmation link to the user: {message}",
|
||||||
"info": "Confirm email, send repeatedly to:",
|
"info": "Confirm email, send repeatedly to:",
|
||||||
"success": "Successfully send the confirmation link to the user's email! ({email})",
|
"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_false": "The last email was sent to the member ({mail}) on {date}.",
|
||||||
"text_true": "The email was confirmed on {date} clock."
|
"text_true": "The email was confirmed."
|
||||||
},
|
},
|
||||||
"user_search": "User search"
|
"user_search": "User search"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,9 @@ export class UserAdmin {
|
|||||||
|
|
||||||
@Field(() => Boolean)
|
@Field(() => Boolean)
|
||||||
hasElopage: boolean
|
hasElopage: boolean
|
||||||
|
|
||||||
|
@Field(() => String, { nullable: true })
|
||||||
|
emailConfirmationSend?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
|
|||||||
@ -22,7 +22,10 @@ import { BalanceRepository } from '../../typeorm/repository/Balance'
|
|||||||
import { calculateDecay } from '../../util/decay'
|
import { calculateDecay } from '../../util/decay'
|
||||||
import { AdminPendingCreation } from '@entity/AdminPendingCreation'
|
import { AdminPendingCreation } from '@entity/AdminPendingCreation'
|
||||||
import { hasElopageBuys } from '../../util/hasElopageBuys'
|
import { hasElopageBuys } from '../../util/hasElopageBuys'
|
||||||
import { User as dbUser } from '@entity/User'
|
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
|
||||||
|
|
||||||
|
// const EMAIL_OPT_IN_REGISTER = 1
|
||||||
|
// const EMAIL_OPT_UNKNOWN = 3 // elopage?
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class AdminResolver {
|
export class AdminResolver {
|
||||||
@ -41,8 +44,28 @@ export class AdminResolver {
|
|||||||
adminUser.lastName = user.lastName
|
adminUser.lastName = user.lastName
|
||||||
adminUser.email = user.email
|
adminUser.email = user.email
|
||||||
adminUser.creation = await getUserCreations(user.id)
|
adminUser.creation = await getUserCreations(user.id)
|
||||||
adminUser.emailChecked = await hasActivatedEmail(user.email)
|
adminUser.emailChecked = user.emailChecked
|
||||||
adminUser.hasElopage = await hasElopageBuys(user.email)
|
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
|
return adminUser
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -61,8 +84,7 @@ export class AdminResolver {
|
|||||||
): Promise<number[]> {
|
): Promise<number[]> {
|
||||||
const userRepository = getCustomRepository(UserRepository)
|
const userRepository = getCustomRepository(UserRepository)
|
||||||
const user = await userRepository.findByEmail(email)
|
const user = await userRepository.findByEmail(email)
|
||||||
const isActivated = await hasActivatedEmail(user.email)
|
if (!user.emailChecked) {
|
||||||
if (!isActivated) {
|
|
||||||
throw new Error('Creation could not be saved, Email is not activated')
|
throw new Error('Creation could not be saved, Email is not activated')
|
||||||
}
|
}
|
||||||
const creations = await getUserCreations(user.id)
|
const creations = await getUserCreations(user.id)
|
||||||
@ -374,8 +396,3 @@ function isCreationValid(creations: number[], amount: number, creationDate: Date
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function hasActivatedEmail(email: string): Promise<boolean> {
|
|
||||||
const user = await dbUser.findOne({ email })
|
|
||||||
return user ? user.emailChecked : false
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user