mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-06 01:25:38 +00:00
Implement enterEmail db request
This commit is contained in:
parent
ebef48ed99
commit
d008eccf68
@ -5,7 +5,6 @@
|
|||||||
:schema="formSchema"
|
:schema="formSchema"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
@input-valid="handleInputValid"
|
@input-valid="handleInputValid"
|
||||||
@submit="handleSubmit"
|
|
||||||
>
|
>
|
||||||
<!-- Wolle <h1>
|
<!-- Wolle <h1>
|
||||||
{{
|
{{
|
||||||
@ -109,7 +108,7 @@ export default {
|
|||||||
message: this.$t('common.validations.email'),
|
message: this.$t('common.validations.email'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// disabled: true,
|
// Wolle disabled: true,
|
||||||
data: null,
|
data: null,
|
||||||
error: null,
|
error: null,
|
||||||
}
|
}
|
||||||
@ -117,7 +116,6 @@ export default {
|
|||||||
mounted: function () {
|
mounted: function () {
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
// Code that will run only after the entire view has been rendered
|
// Code that will run only after the entire view has been rendered
|
||||||
// console.log('mounted !!! ')
|
|
||||||
this.formData.email = this.sliderData.collectedInputData.email
|
this.formData.email = this.sliderData.collectedInputData.email
|
||||||
? this.sliderData.collectedInputData.email
|
? this.sliderData.collectedInputData.email
|
||||||
: ''
|
: ''
|
||||||
@ -129,61 +127,80 @@ export default {
|
|||||||
const { email } = this.data.Signup
|
const { email } = this.data.Signup
|
||||||
return this.$t('components.registration.signup.form.success', { email })
|
return this.$t('components.registration.signup.form.success', { email })
|
||||||
},
|
},
|
||||||
|
sliderIndex() {
|
||||||
|
return this.sliderData.sliderIndex
|
||||||
|
},
|
||||||
validInput() {
|
validInput() {
|
||||||
return isEmail(this.formData.email)
|
return isEmail(this.formData.email)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
sendValidation() {
|
async sendValidation() {
|
||||||
if (this.formData.email && isEmail(this.formData.email)) {
|
if (this.formData.email && isEmail(this.formData.email)) {
|
||||||
this.formData.email = normalizeEmail(this.formData.email)
|
this.formData.email = normalizeEmail(this.formData.email)
|
||||||
}
|
}
|
||||||
const { email } = this.formData
|
const { email } = this.formData
|
||||||
const value = {
|
const value = { email }
|
||||||
email,
|
|
||||||
|
let validated = false
|
||||||
|
if (this.validInput) {
|
||||||
|
await this.handleSubmitVerify()
|
||||||
|
if (this.sliderData.sliders[this.sliderIndex].data.response) {
|
||||||
|
const {email: respnseEmail} = this.sliderData.sliders[this.sliderIndex].data.response.Signup || this.sliderData.sliders[this.sliderIndex].data.response.SignupByInvitation
|
||||||
|
validated = (email === respnseEmail)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.sliderData.validateCallback(this.validInput, value)
|
this.sliderData.validateCallback(validated, value)
|
||||||
},
|
},
|
||||||
handleInput() {
|
async handleInput() {
|
||||||
// this.disabled = true
|
|
||||||
// this.sliderData.validateCallback(false)
|
|
||||||
this.sendValidation()
|
this.sendValidation()
|
||||||
},
|
},
|
||||||
handleInputValid() {
|
async handleInputValid() {
|
||||||
// this.disabemailled = false
|
|
||||||
// const { email } = this.formData
|
|
||||||
// validate in backend?
|
|
||||||
// toaster?
|
|
||||||
// console.log('sendValidation !!! email: ', email)
|
|
||||||
// this.sliderData.validateCallback(true, { email })
|
|
||||||
this.sendValidation()
|
this.sendValidation()
|
||||||
},
|
},
|
||||||
async handleSubmit() {
|
async handleSubmitVerify() {
|
||||||
const mutation = this.token ? SignupByInvitationMutation : SignupMutation
|
const mutation = this.token ? SignupByInvitationMutation : SignupMutation
|
||||||
const { token } = this
|
const { token } = this
|
||||||
const { email } = this.formData
|
const { email } = this.formData
|
||||||
|
const variables = { email, token }
|
||||||
|
|
||||||
try {
|
if (
|
||||||
const response = await this.$apollo.mutate({ mutation, variables: { email, token } })
|
!this.sliderData.sliders[this.sliderIndex].data.request ||
|
||||||
this.data = response.data
|
!this.sliderData.sliders[this.sliderIndex].data.request.variables ||
|
||||||
setTimeout(() => {
|
(this.sliderData.sliders[this.sliderIndex].data.request.variables &&
|
||||||
this.$emit('submit', { email: this.data.Signup.email })
|
!this.sliderData.sliders[this.sliderIndex].data.request.variables.is(variables))
|
||||||
}, 3000)
|
)
|
||||||
} catch (err) {
|
{
|
||||||
const { message } = err
|
this.sliderData.sliders[this.sliderIndex].data.request = { variables }
|
||||||
const mapping = {
|
|
||||||
'A user account with this email already exists': 'email-exists',
|
try {
|
||||||
'Invitation code already used or does not exist': 'invalid-invitation-token',
|
const response = await this.$apollo.mutate({ mutation, variables })
|
||||||
}
|
this.sliderData.sliders[this.sliderIndex].data.response = response.data
|
||||||
for (const [pattern, key] of Object.entries(mapping)) {
|
|
||||||
if (message.includes(pattern))
|
if (this.sliderData.sliders[this.sliderIndex].data.response) {
|
||||||
this.error = {
|
const {email: respnseEmail} = this.sliderData.sliders[this.sliderIndex].data.response.Signup || this.sliderData.sliders[this.sliderIndex].data.response.SignupByInvitation
|
||||||
key,
|
this.$toast.success(
|
||||||
message: this.$t(`components.registration.signup.form.errors.${key}`),
|
this.$t('components.registration.email.form.success', { email: respnseEmail }),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
if (!this.error) {
|
} catch (err) {
|
||||||
this.$toast.error(message)
|
this.sliderData.sliders[this.sliderIndex].data = { request: null, response: null }
|
||||||
|
|
||||||
|
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',
|
||||||
|
}
|
||||||
|
for (const [pattern, key] of Object.entries(mapping)) {
|
||||||
|
if (message.includes(pattern))
|
||||||
|
this.error = {
|
||||||
|
key,
|
||||||
|
message: this.$t(`components.registration.signup.form.errors.${key}`),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this.error) {
|
||||||
|
this.$toast.error(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
:schema="formSchema"
|
:schema="formSchema"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
@input-valid="handleInputValid"
|
@input-valid="handleInputValid"
|
||||||
@submit="handleSubmitVerify"
|
|
||||||
>
|
>
|
||||||
<ds-input
|
<ds-input
|
||||||
:placeholder="$t('components.enter-invite.form.invite-code')"
|
:placeholder="$t('components.enter-invite.form.invite-code')"
|
||||||
@ -70,9 +69,8 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async sendValidation() {
|
async sendValidation() {
|
||||||
const { inviteCode } = this.formData
|
const { inviteCode } = this.formData
|
||||||
const values = {
|
const values = { inviteCode }
|
||||||
inviteCode,
|
|
||||||
}
|
|
||||||
let validated = false
|
let validated = false
|
||||||
if (this.validInput) {
|
if (this.validInput) {
|
||||||
await this.handleSubmitVerify()
|
await this.handleSubmitVerify()
|
||||||
@ -91,22 +89,25 @@ export default {
|
|||||||
const variables = { code: inviteCode }
|
const variables = { code: inviteCode }
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
!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 &&
|
(this.sliderData.sliders[this.sliderIndex].data.request.variables &&
|
||||||
this.sliderData.sliders[this.sliderIndex].data.request.variables.code !== variables.code)
|
!this.sliderData.sliders[this.sliderIndex].data.request.variables.is(variables))
|
||||||
) {
|
) {
|
||||||
this.sliderData.sliders[this.sliderIndex].data.request.variables = variables
|
this.sliderData.sliders[this.sliderIndex].data.request.variables = variables
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await this.$apollo.query({ query: isValidInviteCodeQuery, variables })
|
const response = await this.$apollo.query({ query: isValidInviteCodeQuery, variables })
|
||||||
this.sliderData.sliders[this.sliderIndex].data.response = response.data
|
this.sliderData.sliders[this.sliderIndex].data.response = response.data
|
||||||
if (this.sliderData.sliders[this.sliderIndex].data.response.isValidInviteCode) {
|
|
||||||
|
if (this.sliderData.sliders[this.sliderIndex].data.response && this.sliderData.sliders[this.sliderIndex].data.response.isValidInviteCode) {
|
||||||
this.$toast.success(
|
this.$toast.success(
|
||||||
this.$t('components.registration.inviteCode.form.success', { inviteCode }),
|
this.$t('components.registration.invite-code.form.success', { inviteCode }),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.sliderData.sliders[this.sliderIndex].data.response = { isValidInviteCode: false }
|
this.sliderData.sliders[this.sliderIndex].data.response = { isValidInviteCode: false }
|
||||||
|
|
||||||
const { message } = err
|
const { message } = err
|
||||||
this.$toast.error(message)
|
this.$toast.error(message)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export default {
|
|||||||
message: this.$t('components.enter-nonce.form.validations.length'),
|
message: this.$t('components.enter-nonce.form.validations.length'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// disabled: true,
|
// Wolle disabled: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
|||||||
@ -7,7 +7,15 @@ import Vue from 'vue'
|
|||||||
const plugins = [
|
const plugins = [
|
||||||
(app = {}) => {
|
(app = {}) => {
|
||||||
app.$apollo = {
|
app.$apollo = {
|
||||||
mutate: () => {},
|
mutate: (data) => {
|
||||||
|
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 } } }
|
||||||
|
}
|
||||||
|
throw new Error(`Mutation name not found!`)
|
||||||
|
},
|
||||||
query: (data) => {
|
query: (data) => {
|
||||||
if (JSON.stringify(data).includes('isValidInviteCode')) {
|
if (JSON.stringify(data).includes('isValidInviteCode')) {
|
||||||
return { data: { isValidInviteCode: true } }
|
return { data: { isValidInviteCode: true } }
|
||||||
|
|||||||
@ -87,7 +87,7 @@ export default {
|
|||||||
// title: this.$t('components.registration.create-user-account.title'),
|
// title: this.$t('components.registration.create-user-account.title'),
|
||||||
title: 'Invitation', // Wolle
|
title: 'Invitation', // Wolle
|
||||||
validated: false,
|
validated: false,
|
||||||
data: { request: { variables: null }, response: { isValidInviteCode: false } },
|
data: { request: /* Wolle */{ variables: null }, response: { isValidInviteCode: false } },
|
||||||
button: {
|
button: {
|
||||||
title: 'Next', // Wolle
|
title: 'Next', // Wolle
|
||||||
icon: 'arrow-right',
|
icon: 'arrow-right',
|
||||||
@ -98,8 +98,8 @@ export default {
|
|||||||
name: 'enter-email',
|
name: 'enter-email',
|
||||||
title: 'E-Mail', // Wolle
|
title: 'E-Mail', // Wolle
|
||||||
validated: false,
|
validated: false,
|
||||||
|
data: { request: null, response: null },
|
||||||
button: {
|
button: {
|
||||||
// title: this.sliderData.collectedInputData.emailSend ? 'Resend E-Mail' : 'Send E-Mail', // Wolle
|
|
||||||
title: 'Send E-Mail', // Wolle
|
title: 'Send E-Mail', // Wolle
|
||||||
icon: 'envelope',
|
icon: 'envelope',
|
||||||
callback: this.buttonCallback,
|
callback: this.buttonCallback,
|
||||||
@ -144,7 +144,6 @@ export default {
|
|||||||
sliders = [slidersPortfolio[2], slidersPortfolio[3]]
|
sliders = [slidersPortfolio[2], slidersPortfolio[3]]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// let sliders = slidersPortfolio
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
links,
|
links,
|
||||||
|
|||||||
@ -161,7 +161,12 @@
|
|||||||
"success": "Dein Benutzerkonto wurde erstellt!",
|
"success": "Dein Benutzerkonto wurde erstellt!",
|
||||||
"title": "Benutzerkonto anlegen"
|
"title": "Benutzerkonto anlegen"
|
||||||
},
|
},
|
||||||
"inviteCode": {
|
"email": {
|
||||||
|
"form": {
|
||||||
|
"success": "Gültige E-Mail Adresse <b>{email}</b>!"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"invite-code": {
|
||||||
"form": {
|
"form": {
|
||||||
"success": "Gültiger Einladungs-Code <b>{inviteCode}</b>!"
|
"success": "Gültiger Einladungs-Code <b>{inviteCode}</b>!"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,7 +161,12 @@
|
|||||||
"success": "Your account has been created!",
|
"success": "Your account has been created!",
|
||||||
"title": "Create user account"
|
"title": "Create user account"
|
||||||
},
|
},
|
||||||
"inviteCode": {
|
"email": {
|
||||||
|
"form": {
|
||||||
|
"success": "Valid e-mail address <b>{email}</b>!"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"invite-code": {
|
||||||
"form": {
|
"form": {
|
||||||
"success": "Valid invite code <b>{inviteCode}</b>!"
|
"success": "Valid invite code <b>{inviteCode}</b>!"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user