c67f6d9c92
* fix: fe2 auth error page + various minor UI bugs * clean up & reporting failing email to fe * new mutation to resend verification as guest * email text updates * fixing issues brought up by agi * more text fixes * swapping out space-XXX for gap-XXX
31 lines
948 B
TypeScript
31 lines
948 B
TypeScript
import { Resolvers } from '@/modules/core/graph/generated/graphql'
|
|
import { getUserByEmail } from '@/modules/core/repositories/users'
|
|
import { getPendingToken } from '@/modules/emails/repositories'
|
|
import { requestEmailVerification } from '@/modules/emails/services/verification/request'
|
|
|
|
export = {
|
|
User: {
|
|
async hasPendingVerification(parent) {
|
|
const email = parent.email
|
|
if (!email) return false
|
|
|
|
const token = await getPendingToken({ email })
|
|
return !!token
|
|
}
|
|
},
|
|
Mutation: {
|
|
async requestVerification(_parent, _args, ctx) {
|
|
const { userId } = ctx
|
|
await requestEmailVerification(userId || '')
|
|
return true
|
|
},
|
|
async requestVerificationByEmail(_parent, args) {
|
|
const { email } = args
|
|
const user = await getUserByEmail(email)
|
|
if (!user?.email || user.verified) return false
|
|
await requestEmailVerification(user.id)
|
|
return true
|
|
}
|
|
}
|
|
} as Resolvers
|