Remove mutation 'SignupByInvitation'

This commit is contained in:
Wolfgang Huß 2021-03-03 13:54:47 +01:00
parent f7b7588cbd
commit f7710be95c
14 changed files with 14 additions and 74 deletions

View File

@ -71,6 +71,5 @@ export default {
AddEmailAddress: sendEmailVerificationMail,
requestPasswordReset: sendPasswordResetMail,
Signup: sendSignupMail,
SignupByInvitation: sendSignupMail,
},
}

View File

@ -128,7 +128,6 @@ export default shield(
Mutation: {
'*': deny,
login: allow,
SignupByInvitation: allow,
Signup: or(publicRegistration, isAdmin),
SignupVerification: allow,
UpdateUser: onlyYourself,

View File

@ -10,7 +10,6 @@ type Query {
type Mutation {
Signup(email: String!): EmailAddress
SignupByInvitation(email: String!, token: String!): EmailAddress
SignupVerification(
nonce: String!
email: String!

View File

@ -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
@ -75,13 +75,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 +82,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 +178,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 }
if (!this.sendEmailAgain && this.sliderData.collectedInputData.emailSend) {
return true
@ -201,7 +190,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 +202,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 +223,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))

View File

@ -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!`)
},

View File

@ -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',
)
})
})
})
})
})

View File

@ -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))

View File

@ -183,7 +183,6 @@
"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."
},
"invitation-code": "Dein Einladungscode lautet: <b>{code}</b>",
"minimum-age": "Ich bin 18 Jahre oder älter.",

View File

@ -183,7 +183,6 @@
"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."
},
"invitation-code": "Your invitation code is: <b>{code}</b>",
"minimum-age": "I'm 18 years or older.",

View File

@ -154,7 +154,6 @@
"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."
},
"invitation-code": "Su código de invitación es: <b>{code}</b>",
"minimum-age": "Tengo 18 años o más.",

View File

@ -154,7 +154,6 @@
"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."
},
"invitation-code": "Votre code d'invitation est: <b> {code} </b>",
"minimum-age": "J'ai 18 ans ou plus.",

View File

@ -161,7 +161,6 @@
"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."
},
"invitation-code": null,
"minimum-age": null,

View File

@ -201,7 +201,6 @@
"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."
},
"invitation-code": "O seu código de convite é: <b>{code}</b>",
"minimum-age": "Tenho 18 anos ou mais.",

View File

@ -154,7 +154,6 @@
"description": "Для начала работы введите свой адрес электронной почты:",
"errors": {
"email-exists": "Уже есть учетная запись пользователя с этим адресом электронной почты!",
"invalid-invitation-token": "Похоже, что приглашение уже было использовано. Ссылку из приглашения можно использовать только один раз."
},
"invitation-code": "Код приглашения: <b>{code}</b>",
"minimum-age": "Мне 18 лет или более",