mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
hasElopage is now implemented on apollo
- requires authorization now
This commit is contained in:
parent
5d7241da14
commit
248622f3be
@ -26,6 +26,7 @@ import { UserSettingRepository } from '../../typeorm/repository/UserSettingRepos
|
||||
import { Setting } from '../enum/Setting'
|
||||
import { UserRepository } from '../../typeorm/repository/User'
|
||||
import { LoginUser } from '@entity/LoginUser'
|
||||
import { LoginElopageBuys } from '@entity/LoginElopageBuys'
|
||||
import { LoginUserBackup } from '@entity/LoginUserBackup'
|
||||
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
|
||||
import { sendEMail } from '../../util/sendEMail'
|
||||
@ -570,12 +571,19 @@ export class UserResolver {
|
||||
return new CheckEmailResponse(result.data)
|
||||
}
|
||||
|
||||
@Authorized()
|
||||
@Query(() => Boolean)
|
||||
async hasElopage(@Ctx() context: any): Promise<boolean> {
|
||||
const result = await apiGet(CONFIG.LOGIN_API_URL + 'hasElopage?session_id=' + context.sessionId)
|
||||
if (!result.success) {
|
||||
throw new Error(result.data)
|
||||
// const result = await apiGet(CONFIG.LOGIN_API_URL + 'hasElopage?session_id=' + context.sessionId)
|
||||
const userRepository = getCustomRepository(UserRepository)
|
||||
const userEntity = await userRepository.findByPubkeyHex(context.pubKey).catch()
|
||||
|
||||
if (!userEntity) {
|
||||
return false
|
||||
}
|
||||
return result.data.hasElopage
|
||||
|
||||
const elopageBuyCount = await LoginElopageBuys.count({ payerEmail: userEntity.email })
|
||||
|
||||
return elopageBuyCount > 0
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user