mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Remove mutation 'SignupByInvitation'
This commit is contained in:
parent
f7b7588cbd
commit
f7710be95c
@ -71,6 +71,5 @@ export default {
|
|||||||
AddEmailAddress: sendEmailVerificationMail,
|
AddEmailAddress: sendEmailVerificationMail,
|
||||||
requestPasswordReset: sendPasswordResetMail,
|
requestPasswordReset: sendPasswordResetMail,
|
||||||
Signup: sendSignupMail,
|
Signup: sendSignupMail,
|
||||||
SignupByInvitation: sendSignupMail,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,7 +128,6 @@ export default shield(
|
|||||||
Mutation: {
|
Mutation: {
|
||||||
'*': deny,
|
'*': deny,
|
||||||
login: allow,
|
login: allow,
|
||||||
SignupByInvitation: allow,
|
|
||||||
Signup: or(publicRegistration, isAdmin),
|
Signup: or(publicRegistration, isAdmin),
|
||||||
SignupVerification: allow,
|
SignupVerification: allow,
|
||||||
UpdateUser: onlyYourself,
|
UpdateUser: onlyYourself,
|
||||||
|
|||||||
@ -10,7 +10,6 @@ type Query {
|
|||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
Signup(email: String!): EmailAddress
|
Signup(email: String!): EmailAddress
|
||||||
SignupByInvitation(email: String!, token: String!): EmailAddress
|
|
||||||
SignupVerification(
|
SignupVerification(
|
||||||
nonce: String!
|
nonce: String!
|
||||||
email: String!
|
email: String!
|
||||||
|
|||||||
@ -13,10 +13,10 @@
|
|||||||
: $t('components.registration.signup.title', metadata)
|
: $t('components.registration.signup.title', metadata)
|
||||||
}}
|
}}
|
||||||
</h1> -->
|
</h1> -->
|
||||||
<ds-text
|
<!-- Wolle <ds-text
|
||||||
v-if="token"
|
v-if="token"
|
||||||
v-html="$t('registration.signup.form.invitation-code', { code: token })"
|
v-html="$t('registration.signup.form.invitation-code', { code: token })"
|
||||||
/>
|
/> -->
|
||||||
<ds-text>
|
<ds-text>
|
||||||
{{
|
{{
|
||||||
invitation
|
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 {
|
export default {
|
||||||
name: 'RegistrationSlideEmail',
|
name: 'RegistrationSlideEmail',
|
||||||
components: {
|
components: {
|
||||||
@ -89,8 +82,8 @@ export default {
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
sliderData: { type: Object, required: true },
|
sliderData: { type: Object, required: true },
|
||||||
token: { type: String, default: null }, // Wolle not used???
|
// token: { type: String, default: null }, // Wolle not used???
|
||||||
invitation: { type: Boolean, default: false },
|
invitation: { type: Boolean, default: false }, // Wolle ???
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -185,15 +178,11 @@ export default {
|
|||||||
this.sliderData.sliders[this.sliderIndex].data.request &&
|
this.sliderData.sliders[this.sliderIndex].data.request &&
|
||||||
this.sliderData.sliders[this.sliderIndex].data.request.variables &&
|
this.sliderData.sliders[this.sliderIndex].data.request.variables &&
|
||||||
this.sliderData.sliders[this.sliderIndex].data.request.variables.email === variables.email
|
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() {
|
async onNextClick() {
|
||||||
const mutation = this.token ? SignupByInvitationMutation : SignupMutation
|
|
||||||
const { token } = this
|
|
||||||
const { email } = this.formData
|
const { email } = this.formData
|
||||||
const variables = { email, token }
|
const variables = { email }
|
||||||
|
|
||||||
if (!this.sendEmailAgain && this.sliderData.collectedInputData.emailSend) {
|
if (!this.sendEmailAgain && this.sliderData.collectedInputData.emailSend) {
|
||||||
return true
|
return true
|
||||||
@ -201,7 +190,7 @@ export default {
|
|||||||
|
|
||||||
if (this.sendEmailAgain || !this.isVariablesRequested(variables)) {
|
if (this.sendEmailAgain || !this.isVariablesRequested(variables)) {
|
||||||
try {
|
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.setSliderValuesCallback(
|
||||||
this.sliderData.sliders[this.sliderIndex].validated,
|
this.sliderData.sliders[this.sliderIndex].validated,
|
||||||
{ sliderData: { request: { variables }, response: response.data } },
|
{ sliderData: { request: { variables }, response: response.data } },
|
||||||
@ -213,9 +202,9 @@ export default {
|
|||||||
})
|
})
|
||||||
this.setButtonValues()
|
this.setButtonValues()
|
||||||
|
|
||||||
const { email: respnseEmail } =
|
const { email: respnseEmail } = this.sliderData.sliders[
|
||||||
this.sliderData.sliders[this.sliderIndex].data.response.Signup ||
|
this.sliderIndex
|
||||||
this.sliderData.sliders[this.sliderIndex].data.response.SignupByInvitation
|
].data.response.Signup
|
||||||
this.$toast.success(
|
this.$toast.success(
|
||||||
this.$t('components.registration.email.form.success', { email: respnseEmail }),
|
this.$t('components.registration.email.form.success', { email: respnseEmail }),
|
||||||
)
|
)
|
||||||
@ -234,7 +223,7 @@ export default {
|
|||||||
const { message } = err
|
const { message } = err
|
||||||
const mapping = {
|
const mapping = {
|
||||||
'A user account with this email already exists': 'email-exists',
|
'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)) {
|
for (const [pattern, key] of Object.entries(mapping)) {
|
||||||
if (message.includes(pattern))
|
if (message.includes(pattern))
|
||||||
|
|||||||
@ -14,11 +14,8 @@ const plugins = [
|
|||||||
if (JSON.stringify(data).includes('Signup')) {
|
if (JSON.stringify(data).includes('Signup')) {
|
||||||
return { data: { Signup: { email: data.variables.email } } }
|
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')) {
|
if (JSON.stringify(data).includes('SignupVerification')) {
|
||||||
return { data: { SignupByInvitation: { ...data.variables } } }
|
return { data: { SignupVerification: { ...data.variables } } }
|
||||||
}
|
}
|
||||||
throw new Error(`Mutation name not found!`)
|
throw new Error(`Mutation name not found!`)
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { config, mount } from '@vue/test-utils'
|
import { config, mount } from '@vue/test-utils'
|
||||||
import Signup, { SignupMutation, SignupByInvitationMutation } from './Signup'
|
import Signup, { SignupMutation } from './Signup'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
@ -98,12 +98,6 @@ describe('Signup', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('submit', () => {
|
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 () => {
|
it('delivers invitation token to backend', async () => {
|
||||||
await action()
|
await action()
|
||||||
const expected = expect.objectContaining({
|
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)
|
: $t('components.registration.signup.title', metadata)
|
||||||
}}
|
}}
|
||||||
</h1>
|
</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-space margin-botton="large">
|
||||||
<ds-text>
|
<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 {
|
export default {
|
||||||
name: 'Signup',
|
name: 'Signup',
|
||||||
components: {
|
components: {
|
||||||
SweetalertIcon,
|
SweetalertIcon,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
token: { type: String, default: null },
|
|
||||||
invitation: { type: Boolean, default: false },
|
invitation: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -126,12 +115,10 @@ export default {
|
|||||||
this.disabled = false
|
this.disabled = false
|
||||||
},
|
},
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
const mutation = this.token ? SignupByInvitationMutation : SignupMutation
|
|
||||||
const { token } = this
|
|
||||||
const { email } = this.formData
|
const { email } = this.formData
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await this.$apollo.mutate({ mutation, variables: { email, token } })
|
const response = await this.$apollo.mutate({ SignupMutation, variables: { email } })
|
||||||
this.data = response.data
|
this.data = response.data
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$emit('submit', { email: this.data.Signup.email })
|
this.$emit('submit', { email: this.data.Signup.email })
|
||||||
@ -140,7 +127,7 @@ export default {
|
|||||||
const { message } = err
|
const { message } = err
|
||||||
const mapping = {
|
const mapping = {
|
||||||
'A user account with this email already exists': 'email-exists',
|
'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)) {
|
for (const [pattern, key] of Object.entries(mapping)) {
|
||||||
if (message.includes(pattern))
|
if (message.includes(pattern))
|
||||||
|
|||||||
@ -183,7 +183,6 @@
|
|||||||
"description": "Um loszulegen, kannst Du Dich hier kostenfrei registrieren:",
|
"description": "Um loszulegen, kannst Du Dich hier kostenfrei registrieren:",
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": "Es gibt schon ein Benutzerkonto mit dieser E-Mail-Adresse!",
|
"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>",
|
"invitation-code": "Dein Einladungscode lautet: <b>{code}</b>",
|
||||||
"minimum-age": "Ich bin 18 Jahre oder älter.",
|
"minimum-age": "Ich bin 18 Jahre oder älter.",
|
||||||
|
|||||||
@ -183,7 +183,6 @@
|
|||||||
"description": "To get started, you can register here for free:",
|
"description": "To get started, you can register here for free:",
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": "There is already a user account with this e-mail address!",
|
"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>",
|
"invitation-code": "Your invitation code is: <b>{code}</b>",
|
||||||
"minimum-age": "I'm 18 years or older.",
|
"minimum-age": "I'm 18 years or older.",
|
||||||
|
|||||||
@ -154,7 +154,6 @@
|
|||||||
"description": "Para empezar, introduzca su dirección de correo electrónico:",
|
"description": "Para empezar, introduzca su dirección de correo electrónico:",
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": "¡Ya hay una cuenta de usuario con esta dirección de correo electrónico!",
|
"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>",
|
"invitation-code": "Su código de invitación es: <b>{code}</b>",
|
||||||
"minimum-age": "Tengo 18 años o más.",
|
"minimum-age": "Tengo 18 años o más.",
|
||||||
|
|||||||
@ -154,7 +154,6 @@
|
|||||||
"description": "Pour commencer, entrez votre adresse mail :",
|
"description": "Pour commencer, entrez votre adresse mail :",
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": "Il existe déjà un compte utilisateur avec cette adresse mail!",
|
"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>",
|
"invitation-code": "Votre code d'invitation est: <b> {code} </b>",
|
||||||
"minimum-age": "J'ai 18 ans ou plus.",
|
"minimum-age": "J'ai 18 ans ou plus.",
|
||||||
|
|||||||
@ -161,7 +161,6 @@
|
|||||||
"description": null,
|
"description": null,
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": null,
|
"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,
|
"invitation-code": null,
|
||||||
"minimum-age": null,
|
"minimum-age": null,
|
||||||
|
|||||||
@ -201,7 +201,6 @@
|
|||||||
"description": "Para começar, digite seu endereço de e-mail:",
|
"description": "Para começar, digite seu endereço de e-mail:",
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": "Já existe uma conta de usuário com este endereço de e-mail!",
|
"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>",
|
"invitation-code": "O seu código de convite é: <b>{code}</b>",
|
||||||
"minimum-age": "Tenho 18 anos ou mais.",
|
"minimum-age": "Tenho 18 anos ou mais.",
|
||||||
|
|||||||
@ -154,7 +154,6 @@
|
|||||||
"description": "Для начала работы введите свой адрес электронной почты:",
|
"description": "Для начала работы введите свой адрес электронной почты:",
|
||||||
"errors": {
|
"errors": {
|
||||||
"email-exists": "Уже есть учетная запись пользователя с этим адресом электронной почты!",
|
"email-exists": "Уже есть учетная запись пользователя с этим адресом электронной почты!",
|
||||||
"invalid-invitation-token": "Похоже, что приглашение уже было использовано. Ссылку из приглашения можно использовать только один раз."
|
|
||||||
},
|
},
|
||||||
"invitation-code": "Код приглашения: <b>{code}</b>",
|
"invitation-code": "Код приглашения: <b>{code}</b>",
|
||||||
"minimum-age": "Мне 18 лет или более",
|
"minimum-age": "Мне 18 лет или более",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user