mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Create a query to check if OptIn code is not to old.
This commit is contained in:
parent
08dd7c3518
commit
c3f7953bdb
@ -486,8 +486,8 @@ export class UserResolver {
|
||||
|
||||
// Code is only valid for 10minutes
|
||||
const timeElapsed = Date.now() - new Date(optInCode.updatedAt).getTime()
|
||||
if (timeElapsed > 10 * 60 * 1000) {
|
||||
throw new Error('Code is older than 10 minutes')
|
||||
if (timeElapsed > parseInt(CONFIG.RESEND_TIME.toString()) * 60 * 1000) {
|
||||
throw new Error('Code is older than ' + parseInt(CONFIG.RESEND_TIME.toString()) + ' minutes')
|
||||
}
|
||||
|
||||
// load user
|
||||
@ -558,6 +558,19 @@ export class UserResolver {
|
||||
return true
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.QUERY_OPT_IN])
|
||||
@Query(() => Boolean)
|
||||
async queryOptIn(@Arg('optIn') optIn: string): Promise<boolean> {
|
||||
const optInCode = await LoginEmailOptIn.findOneOrFail({ verificationCode: optIn })
|
||||
console.log('optInCode', optInCode)
|
||||
// Code is only valid for 10minutes
|
||||
const timeElapsed = Date.now() - new Date(optInCode.updatedAt).getTime()
|
||||
if (timeElapsed > parseInt(CONFIG.RESEND_TIME.toString()) * 60 * 1000) {
|
||||
throw new Error('Code is older than ' + parseInt(CONFIG.RESEND_TIME.toString()) + ' minutes')
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.UPDATE_USER_INFOS])
|
||||
@Mutation(() => Boolean)
|
||||
async updateUserInfos(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user