mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
merging invite codes in schema
This commit is contained in:
commit
bb429890af
@ -17,6 +17,7 @@ PRIVATE_KEY_PASSPHRASE="a7dsf78sadg87ad87sfagsadg78"
|
||||
SENTRY_DSN_BACKEND=
|
||||
COMMIT=
|
||||
PUBLIC_REGISTRATION=false
|
||||
INVITE_REGISTRATION=true
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
|
||||
@ -83,6 +83,7 @@ const options = {
|
||||
APPLICATION_NAME: metadata.APPLICATION_NAME,
|
||||
ORGANIZATION_URL: links.ORGANIZATION,
|
||||
PUBLIC_REGISTRATION: env.PUBLIC_REGISTRATION === 'true',
|
||||
INVITE_REGISTRATION: env.INVITE_REGISTRATION === 'true',
|
||||
}
|
||||
|
||||
// Check if all required configs are present
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<slot :name="sliderData.sliders[sliderIndex].name" />
|
||||
|
||||
<ds-flex>
|
||||
<ds-flex-item v-if="sliderData.sliders.length > 1" :centered="true">
|
||||
<ds-flex-item v-if="multipleSliders" :centered="true">
|
||||
<div
|
||||
v-for="(slider, index) in sliderData.sliders"
|
||||
:key="slider.name"
|
||||
@ -30,7 +30,7 @@
|
||||
</ds-flex-item>
|
||||
<ds-flex-item>
|
||||
<base-button
|
||||
style="float: right"
|
||||
:style="multipleSliders && 'float: right'"
|
||||
:icon="sliderData.sliders[sliderIndex].button.icon"
|
||||
type="submit"
|
||||
filled
|
||||
@ -57,6 +57,9 @@ export default {
|
||||
sliderIndex() {
|
||||
return this.sliderData.sliderIndex // to have a shorter notation
|
||||
},
|
||||
multipleSliders() {
|
||||
return this.sliderData.sliders.length > 1
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async onNextClick() {
|
||||
|
||||
@ -285,7 +285,7 @@ export default {
|
||||
const locale = this.$i18n.locale()
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: SignupVerificationMutation,
|
||||
mutation: SignupVerificationMutation, // Wolle add nonce in 'SignupVerificationMutation' definition in case
|
||||
variables: {
|
||||
name,
|
||||
password,
|
||||
|
||||
@ -13,10 +13,10 @@
|
||||
: $t('components.registration.signup.title', metadata)
|
||||
}}
|
||||
</h1> -->
|
||||
<ds-text
|
||||
<!-- Wolle <ds-text
|
||||
v-if="token"
|
||||
v-html="$t('registration.signup.form.invitation-code', { code: token })"
|
||||
/>
|
||||
/> -->
|
||||
<ds-text>
|
||||
{{
|
||||
invitation
|
||||
@ -68,6 +68,7 @@ import { isEmail } from 'validator'
|
||||
import normalizeEmail from '~/components/utils/NormalizeEmail'
|
||||
// Wolle import { SweetalertIcon } from 'vue-sweetalert-icons'
|
||||
|
||||
// Wolle add nonce in in case
|
||||
export const SignupMutation = gql`
|
||||
mutation($email: String!) {
|
||||
Signup(email: $email) {
|
||||
@ -75,13 +76,6 @@ export const SignupMutation = gql`
|
||||
}
|
||||
}
|
||||
`
|
||||
export const SignupByInvitationMutation = gql`
|
||||
mutation($email: String!, $token: String!) {
|
||||
SignupByInvitation(email: $email, token: $token) {
|
||||
email
|
||||
}
|
||||
}
|
||||
`
|
||||
export default {
|
||||
name: 'RegistrationSlideEmail',
|
||||
components: {
|
||||
@ -89,8 +83,8 @@ export default {
|
||||
},
|
||||
props: {
|
||||
sliderData: { type: Object, required: true },
|
||||
token: { type: String, default: null }, // Wolle not used???
|
||||
invitation: { type: Boolean, default: false },
|
||||
// token: { type: String, default: null }, // Wolle not used???
|
||||
invitation: { type: Boolean, default: false }, // Wolle ???
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -185,15 +179,11 @@ export default {
|
||||
this.sliderData.sliders[this.sliderIndex].data.request &&
|
||||
this.sliderData.sliders[this.sliderIndex].data.request.variables &&
|
||||
this.sliderData.sliders[this.sliderIndex].data.request.variables.email === variables.email
|
||||
// Wolle &&
|
||||
// this.sliderData.sliders[this.sliderIndex].data.request.variables.token === variables.code
|
||||
)
|
||||
},
|
||||
async onNextClick() {
|
||||
const mutation = this.token ? SignupByInvitationMutation : SignupMutation
|
||||
const { token } = this
|
||||
const { email } = this.formData
|
||||
const variables = { email, token }
|
||||
const variables = { email } // Wolle add nonce in case
|
||||
|
||||
if (!this.sendEmailAgain && this.sliderData.collectedInputData.emailSend) {
|
||||
return true
|
||||
@ -201,7 +191,7 @@ export default {
|
||||
|
||||
if (this.sendEmailAgain || !this.isVariablesRequested(variables)) {
|
||||
try {
|
||||
const response = await this.$apollo.mutate({ mutation, variables }) // e-mail is send in emailMiddleware of backend
|
||||
const response = await this.$apollo.mutate({ SignupMutation, variables }) // e-mail is send in emailMiddleware of backend
|
||||
this.sliderData.setSliderValuesCallback(
|
||||
this.sliderData.sliders[this.sliderIndex].validated,
|
||||
{ sliderData: { request: { variables }, response: response.data } },
|
||||
@ -213,9 +203,9 @@ export default {
|
||||
})
|
||||
this.setButtonValues()
|
||||
|
||||
const { email: respnseEmail } =
|
||||
this.sliderData.sliders[this.sliderIndex].data.response.Signup ||
|
||||
this.sliderData.sliders[this.sliderIndex].data.response.SignupByInvitation
|
||||
const { email: respnseEmail } = this.sliderData.sliders[
|
||||
this.sliderIndex
|
||||
].data.response.Signup
|
||||
this.$toast.success(
|
||||
this.$t('components.registration.email.form.success', { email: respnseEmail }),
|
||||
)
|
||||
@ -234,7 +224,7 @@ export default {
|
||||
const { message } = err
|
||||
const mapping = {
|
||||
'A user account with this email already exists': 'email-exists',
|
||||
'Invitation code already used or does not exist': 'invalid-invitation-token',
|
||||
// Wolle 'Invitation code already used or does not exist': 'invalid-invitation-token',
|
||||
}
|
||||
for (const [pattern, key] of Object.entries(mapping)) {
|
||||
if (message.includes(pattern))
|
||||
|
||||
@ -14,11 +14,8 @@ const plugins = [
|
||||
if (JSON.stringify(data).includes('Signup')) {
|
||||
return { data: { Signup: { email: data.variables.email } } }
|
||||
}
|
||||
if (JSON.stringify(data).includes('SignupByInvitation')) {
|
||||
return { data: { SignupByInvitation: { email: data.variables.email } } }
|
||||
}
|
||||
if (JSON.stringify(data).includes('SignupVerification')) {
|
||||
return { data: { SignupByInvitation: { ...data.variables } } }
|
||||
return { data: { SignupVerification: { ...data.variables } } }
|
||||
}
|
||||
throw new Error(`Mutation name not found!`)
|
||||
},
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import Signup, { SignupMutation, SignupByInvitationMutation } from './Signup'
|
||||
import Signup, { SignupMutation } from './Signup'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
@ -98,12 +98,6 @@ describe('Signup', () => {
|
||||
})
|
||||
|
||||
describe('submit', () => {
|
||||
it('calls SignupByInvitation graphql mutation', async () => {
|
||||
await action()
|
||||
const expected = expect.objectContaining({ mutation: SignupByInvitationMutation })
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected)
|
||||
})
|
||||
|
||||
it('delivers invitation token to backend', async () => {
|
||||
await action()
|
||||
const expected = expect.objectContaining({
|
||||
@ -128,23 +122,6 @@ describe('Signup', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('in case the invitation code was incorrect', () => {
|
||||
beforeEach(() => {
|
||||
mocks.$apollo.mutate = jest
|
||||
.fn()
|
||||
.mockRejectedValue(
|
||||
new Error('UserInputError: Invitation code already used or does not exist.'),
|
||||
)
|
||||
})
|
||||
|
||||
it('explains the error', async () => {
|
||||
await action()
|
||||
expect(mocks.$t).toHaveBeenCalledWith(
|
||||
'components.registration.signup.form.errors.invalid-invitation-token',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -14,9 +14,6 @@
|
||||
: $t('components.registration.signup.title', metadata)
|
||||
}}
|
||||
</h1>
|
||||
<ds-space v-if="token" margin-botton="large">
|
||||
<ds-text v-html="$t('registration.signup.form.invitation-code', { code: token })" />
|
||||
</ds-space>
|
||||
<ds-space margin-botton="large">
|
||||
<ds-text>
|
||||
{{
|
||||
@ -78,20 +75,12 @@ export const SignupMutation = gql`
|
||||
}
|
||||
}
|
||||
`
|
||||
export const SignupByInvitationMutation = gql`
|
||||
mutation($email: String!, $token: String!) {
|
||||
SignupByInvitation(email: $email, token: $token) {
|
||||
email
|
||||
}
|
||||
}
|
||||
`
|
||||
export default {
|
||||
name: 'Signup',
|
||||
components: {
|
||||
SweetalertIcon,
|
||||
},
|
||||
props: {
|
||||
token: { type: String, default: null },
|
||||
invitation: { type: Boolean, default: false },
|
||||
},
|
||||
data() {
|
||||
@ -126,12 +115,10 @@ export default {
|
||||
this.disabled = false
|
||||
},
|
||||
async handleSubmit() {
|
||||
const mutation = this.token ? SignupByInvitationMutation : SignupMutation
|
||||
const { token } = this
|
||||
const { email } = this.formData
|
||||
|
||||
try {
|
||||
const response = await this.$apollo.mutate({ mutation, variables: { email, token } })
|
||||
const response = await this.$apollo.mutate({ SignupMutation, variables: { email } })
|
||||
this.data = response.data
|
||||
setTimeout(() => {
|
||||
this.$emit('submit', { email: this.data.Signup.email })
|
||||
@ -140,7 +127,7 @@ export default {
|
||||
const { message } = err
|
||||
const mapping = {
|
||||
'A user account with this email already exists': 'email-exists',
|
||||
'Invitation code already used or does not exist': 'invalid-invitation-token',
|
||||
// Wolle 'Invitation code already used or does not exist': 'invalid-invitation-token',
|
||||
}
|
||||
for (const [pattern, key] of Object.entries(mapping)) {
|
||||
if (message.includes(pattern))
|
||||
|
||||
@ -29,6 +29,8 @@ const sentry = {
|
||||
const options = {
|
||||
VERSION: process.env.VERSION || pkg.version,
|
||||
DESCRIPTION: process.env.DESCRIPTION || pkg.description,
|
||||
PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true',
|
||||
INVITE_REGISTRATION: process.env.INVITE_REGISTRATION === 'true',
|
||||
// Cookies
|
||||
COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default
|
||||
COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly
|
||||
|
||||
@ -182,8 +182,7 @@
|
||||
"data-privacy": "Ich habe die Datenschutzerklärung gelesen und verstanden.",
|
||||
"description": "Um loszulegen, kannst Du Dich hier kostenfrei registrieren:",
|
||||
"errors": {
|
||||
"email-exists": "Es gibt schon ein Benutzerkonto mit dieser E-Mail-Adresse!",
|
||||
"invalid-invitation-token": "Es sieht so aus, als ob der Einladungscode schon eingelöst wurde. Jeder Code kann nur einmalig benutzt werden."
|
||||
"email-exists": "Es gibt schon ein Benutzerkonto mit dieser E-Mail-Adresse!"
|
||||
},
|
||||
"invitation-code": "Dein Einladungscode lautet: <b>{code}</b>",
|
||||
"minimum-age": "Ich bin 18 Jahre oder älter.",
|
||||
|
||||
@ -182,8 +182,7 @@
|
||||
"data-privacy": "I have read and understood the privacy statement.",
|
||||
"description": "To get started, you can register here for free:",
|
||||
"errors": {
|
||||
"email-exists": "There is already a user account with this e-mail address!",
|
||||
"invalid-invitation-token": "It looks like as if the invitation has been used already. Invitation links can only be used once."
|
||||
"email-exists": "There is already a user account with this e-mail address!"
|
||||
},
|
||||
"invitation-code": "Your invitation code is: <b>{code}</b>",
|
||||
"minimum-age": "I'm 18 years or older.",
|
||||
|
||||
@ -153,8 +153,7 @@
|
||||
"data-privacy": "He leido y entendido la declaración de protección de datos.",
|
||||
"description": "Para empezar, introduzca su dirección de correo electrónico:",
|
||||
"errors": {
|
||||
"email-exists": "¡Ya hay una cuenta de usuario con esta dirección de correo electrónico!",
|
||||
"invalid-invitation-token": "Parece que el código de invitación ya ha sido canjeado. Cada código sólo se puede utilizar una vez."
|
||||
"email-exists": "¡Ya hay una cuenta de usuario con esta dirección de correo electrónico!"
|
||||
},
|
||||
"invitation-code": "Su código de invitación es: <b>{code}</b>",
|
||||
"minimum-age": "Tengo 18 años o más.",
|
||||
|
||||
@ -153,8 +153,7 @@
|
||||
"data-privacy": "J'ai lu et compris la Déclaration de confidentialité.",
|
||||
"description": "Pour commencer, entrez votre adresse mail :",
|
||||
"errors": {
|
||||
"email-exists": "Il existe déjà un compte utilisateur avec cette adresse mail!",
|
||||
"invalid-invitation-token": "On dirait que l'invitation a déjà été utilisée. Les liens d'invitation ne peuvent être utilisés qu'une seule fois."
|
||||
"email-exists": "Il existe déjà un compte utilisateur avec cette adresse mail!"
|
||||
},
|
||||
"invitation-code": "Votre code d'invitation est: <b> {code} </b>",
|
||||
"minimum-age": "J'ai 18 ans ou plus.",
|
||||
|
||||
@ -160,8 +160,7 @@
|
||||
"data-privacy": null,
|
||||
"description": null,
|
||||
"errors": {
|
||||
"email-exists": null,
|
||||
"invalid-invitation-token": "Sembra che l'invito sia già stato utilizzato. I link di invito possono essere utilizzati una sola volta."
|
||||
"email-exists": null
|
||||
},
|
||||
"invitation-code": null,
|
||||
"minimum-age": null,
|
||||
|
||||
@ -200,8 +200,7 @@
|
||||
"data-privacy": "Eu li e entendi o Política de Privacidade.",
|
||||
"description": "Para começar, digite seu endereço de e-mail:",
|
||||
"errors": {
|
||||
"email-exists": "Já existe uma conta de usuário com este endereço de e-mail!",
|
||||
"invalid-invitation-token": "Parece que o convite já foi usado. Os links para convites só podem ser usados uma vez."
|
||||
"email-exists": "Já existe uma conta de usuário com este endereço de e-mail!"
|
||||
},
|
||||
"invitation-code": "O seu código de convite é: <b>{code}</b>",
|
||||
"minimum-age": "Tenho 18 anos ou mais.",
|
||||
|
||||
@ -153,8 +153,7 @@
|
||||
"data-privacy": "Я прочитал и понял Заявление о конфиденциальности",
|
||||
"description": "Для начала работы введите свой адрес электронной почты:",
|
||||
"errors": {
|
||||
"email-exists": "Уже есть учетная запись пользователя с этим адресом электронной почты!",
|
||||
"invalid-invitation-token": "Похоже, что приглашение уже было использовано. Ссылку из приглашения можно использовать только один раз."
|
||||
"email-exists": "Уже есть учетная запись пользователя с этим адресом электронной почты!"
|
||||
},
|
||||
"invitation-code": "Код приглашения: <b>{code}</b>",
|
||||
"minimum-age": "Мне 18 лет или более",
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
<template>
|
||||
<section class="registration-form">
|
||||
<base-card>
|
||||
<registration-slider
|
||||
<!-- <section class="registration-form">
|
||||
<base-card> -->
|
||||
<!-- <registration-slider
|
||||
v-if="registrationType"
|
||||
:registrationType="registrationType"
|
||||
:overwriteSliderData="overwriteSliderData"
|
||||
/>
|
||||
<ds-space v-else centered>
|
||||
/> -->
|
||||
<registration-slider
|
||||
:registrationType="registrationType"
|
||||
:overwriteSliderData="overwriteSliderData"
|
||||
/>
|
||||
<!-- <ds-space v-else centered>
|
||||
<hc-empty icon="events" :message="$t('components.registration.signup.unavailable')" />
|
||||
<nuxt-link to="/login">{{ $t('site.back-to-login') }}</nuxt-link>
|
||||
</ds-space>
|
||||
@ -14,19 +18,19 @@
|
||||
<locale-switch offset="5" />
|
||||
</template>
|
||||
</base-card>
|
||||
</section>
|
||||
</section> -->
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HcEmpty from '~/components/Empty/Empty'
|
||||
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
||||
// import HcEmpty from '~/components/Empty/Empty'
|
||||
// import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
||||
import RegistrationSlider from '~/components/Registration/RegistrationSlider'
|
||||
|
||||
export default {
|
||||
name: 'Registration',
|
||||
components: {
|
||||
HcEmpty,
|
||||
LocaleSwitch,
|
||||
// HcEmpty,
|
||||
// LocaleSwitch,
|
||||
RegistrationSlider,
|
||||
},
|
||||
data() {
|
||||
@ -48,8 +52,8 @@ export default {
|
||||
redirect('/')
|
||||
}
|
||||
return {
|
||||
publicRegistration: app.$env.PUBLIC_REGISTRATION === 'true',
|
||||
inviteRegistration: app.$env.INVITE_REGISTRATION === 'true',
|
||||
publicRegistration: app.$env.PUBLIC_REGISTRATION,
|
||||
inviteRegistration: app.$env.INVITE_REGISTRATION,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
@ -22,7 +22,7 @@ export default {
|
||||
},
|
||||
asyncData({ app }) {
|
||||
return {
|
||||
publicRegistration: app.$env.PUBLIC_REGISTRATION === 'true',
|
||||
publicRegistration: app.$env.PUBLIC_REGISTRATION,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user