Implementation of signup to Klicktipp.

This commit is contained in:
elweyn 2021-09-10 11:45:41 +02:00
parent 1b6cb61530
commit c5a65da94c
7 changed files with 26 additions and 8 deletions

View File

@ -5,8 +5,16 @@ import CONFIG from '../config'
const klicktippConnector = new KlicktippConnector()
export const signin = async (email: string, language: string): Promise<boolean> => {
const fields = {}
export const signin = async (
email: string,
language: string,
firstName: string,
lastName: string,
): Promise<boolean> => {
const fields = {
fieldFirstName: firstName,
fieldLastName: lastName,
}
const apiKey = language === 'de' ? CONFIG.KLICKTIPP_APIKEY_DE : CONFIG.KLICKTIPP_APIKEY_EN
const result = await klicktippConnector.signin(apiKey, email, fields)
return result

View File

@ -8,6 +8,8 @@ export class CheckEmailResponse {
this.sessionId = json.session_id
this.email = json.user.email
this.language = json.user.language
this.firstName = json.user.first_name
this.lastName = json.user.last_name
}
@Field(() => Number)
@ -16,6 +18,12 @@ export class CheckEmailResponse {
@Field(() => String)
email: string
@Field(() => String)
firstName: string
@Field(() => String)
lastName: string
@Field(() => String)
language: string
}

View File

@ -166,7 +166,9 @@ export class UserResolver {
@Query(() => CheckEmailResponse)
@UseMiddleware(klicktippRegistrationMiddleware)
async checkEmail(@Arg('optin') optin: string): Promise<CheckEmailResponse> {
const result = await apiGet(CONFIG.LOGIN_API_URL + 'checkEmail/' + optin)
const result = await apiGet(
CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin,
)
if (!result.success) {
throw new Error(result.data)
}

View File

@ -10,6 +10,6 @@ export const klicktippRegistrationMiddleware: MiddlewareFn = async (
// Do Something here before resolver is called
const result = await next()
// Do Something here after resolver is completed
signin(result.data.checkEmail.email, result.data.checkEmail.language)
signin(result.email, result.language, result.firstName, result.lastName)
return result
}

View File

@ -127,7 +127,7 @@
},
"checkEmail": {
"title": "Email wird verifiziert",
"error-text": "Email konnte nicht verifiziert werden."
"errorText": "Email konnte nicht verifiziert werden."
},
"thx": {
"title": "Danke!",

View File

@ -127,7 +127,7 @@
},
"checkEmail": {
"title": "Verifing email",
"error-text": "Could not verify the email."
"errorText": "Could not verify the email."
},
"thx": {
"title": "Thank you!",

View File

@ -5,10 +5,10 @@
<div class="header-body text-center mb-7">
<b-row class="justify-content-center">
<b-col xl="5" lg="6" md="8" class="px-2">
<h1>{{ $t('check-email.title') }}</h1>
<h1>{{ $t('checkEmail.title') }}</h1>
<div class="pb-4" v-if="!pending">
<span v-if="!authenticated">
{{ $t('check-email.error-text') }}
{{ $t('checkEmail.errorText') }}
</span>
</div>
</b-col>