mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Changed the error handling when klicktipp not accessible.
This commit is contained in:
parent
7b11c2212f
commit
7084bcb9c0
@ -41,7 +41,7 @@ export const getKlickTippUser = async (email: string): Promise<any> => {
|
||||
const result = await klicktippConnector.subscriberGet(subscriberId)
|
||||
return result
|
||||
}
|
||||
throw new Error()
|
||||
return false
|
||||
}
|
||||
|
||||
export const loginKlicktippUser = async (): Promise<boolean> => {
|
||||
@ -57,7 +57,7 @@ export const untagUser = async (email: string, tagId: string): Promise<boolean>
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.untag(email, tagId)
|
||||
}
|
||||
throw new Error()
|
||||
return false
|
||||
}
|
||||
|
||||
export const tagUser = async (email: string, tagIds: string): Promise<boolean> => {
|
||||
@ -65,7 +65,7 @@ export const tagUser = async (email: string, tagIds: string): Promise<boolean> =
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.tag(email, tagIds)
|
||||
}
|
||||
throw new Error()
|
||||
return false
|
||||
}
|
||||
|
||||
export const getKlicktippTagMap = async () => {
|
||||
@ -73,5 +73,5 @@ export const getKlicktippTagMap = async () => {
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.tagIndex()
|
||||
}
|
||||
throw new Error()
|
||||
return ''
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ const database = {
|
||||
}
|
||||
|
||||
const klicktipp = {
|
||||
KLICKTIPP: process.env.KLICKTIPP === 'true' || false,
|
||||
KLICKTTIPP_API_URL: process.env.KLICKTIPP_API_URL || 'https://api.klicktipp.com',
|
||||
KLICKTIPP_USER: process.env.KLICKTIPP_USER || 'gradido_test',
|
||||
KLICKTIPP_PASSWORD: process.env.KLICKTIPP_PASSWORD || 'secret321',
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { MiddlewareFn } from 'type-graphql'
|
||||
import { signIn, getKlickTippUser } from '../apis/KlicktippController'
|
||||
import { KlickTipp } from '../graphql/models/KlickTipp'
|
||||
import CONFIG from '../config/index'
|
||||
|
||||
export const klicktippRegistrationMiddleware: MiddlewareFn = async (
|
||||
// Only for demo
|
||||
@ -21,8 +22,10 @@ export const klicktippNewsletterStateMiddleware: MiddlewareFn = async (
|
||||
next,
|
||||
) => {
|
||||
const result = await next()
|
||||
const klickTippUser = await getKlickTippUser(result.email)
|
||||
const klickTipp = new KlickTipp(klickTippUser)
|
||||
result.klickTipp = klickTipp
|
||||
if (CONFIG.KLICKTIPP) {
|
||||
const klickTippUser = await getKlickTippUser(result.email)
|
||||
const klickTipp = new KlickTipp(klickTippUser)
|
||||
result.klickTipp = klickTipp
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user