mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Display nice success message on password reset
This commit is contained in:
parent
a501e1145d
commit
de9ed55738
@ -19,7 +19,7 @@
|
|||||||
"form": {
|
"form": {
|
||||||
"description": "Eine Mail zum Zurücksetzen des Passworts wird an die angegebene E-Mail Adresse geschickt.",
|
"description": "Eine Mail zum Zurücksetzen des Passworts wird an die angegebene E-Mail Adresse geschickt.",
|
||||||
"submit": "Email anfordern",
|
"submit": "Email anfordern",
|
||||||
"submitted": "Eine E-Mail zum Zurücksetzen wurde angefordert"
|
"submitted": "E-Mail verschickt an <b>{email}</b>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"editor": {
|
"editor": {
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
"form": {
|
"form": {
|
||||||
"description": "A password reset email will be sent to the given email address.",
|
"description": "A password reset email will be sent to the given email address.",
|
||||||
"submit": "Request email",
|
"submit": "Request email",
|
||||||
"submitted": "Reset email was requested"
|
"submitted": "Email sent to <b>{email}</b>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"editor": {
|
"editor": {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ describe('ProfileSlug', () => {
|
|||||||
$t: jest.fn(),
|
$t: jest.fn(),
|
||||||
$apollo: {
|
$apollo: {
|
||||||
loading: false,
|
loading: false,
|
||||||
mutate: jest.fn().mockResolvedValue(),
|
mutate: jest.fn().mockResolvedValue({ data: { reqestPasswordReset: true } }),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -49,9 +49,19 @@ describe('ProfileSlug', () => {
|
|||||||
expect(mocks.$apollo.mutate).toHaveBeenCalled()
|
expect(mocks.$apollo.mutate).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it.todo('delivers email to backend')
|
it('delivers email to backend', () => {
|
||||||
it.todo('disables form to avoid re-submission')
|
const expected = expect.objectContaining({ variables: { email: 'mail@example.org' } })
|
||||||
it.todo('displays a message that a password email was requested')
|
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('hides form to avoid re-submission', () => {
|
||||||
|
expect(wrapper.find('form').exists()).not.toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('displays a message that a password email was requested', () => {
|
||||||
|
const expected = ['password-reset.form.submitted', { email: 'mail@example.org' }]
|
||||||
|
expect(mocks.$t).toHaveBeenCalledWith(...expected)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('given password reset token as URL param', () => {
|
describe('given password reset token as URL param', () => {
|
||||||
|
|||||||
@ -6,11 +6,13 @@
|
|||||||
<ds-card class="password-reset-card">
|
<ds-card class="password-reset-card">
|
||||||
<ds-space margin="large">
|
<ds-space margin="large">
|
||||||
<ds-form
|
<ds-form
|
||||||
|
v-if="!submitted"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
@input-valid="handleInputValid"
|
@input-valid="handleInputValid"
|
||||||
v-model="formData"
|
v-model="formData"
|
||||||
:schema="formSchema"
|
:schema="formSchema"
|
||||||
@submit="handleSubmit">
|
@submit="handleSubmit"
|
||||||
|
>
|
||||||
<ds-input
|
<ds-input
|
||||||
:placeholder="$t('login.email')"
|
:placeholder="$t('login.email')"
|
||||||
type="email"
|
type="email"
|
||||||
@ -26,10 +28,24 @@
|
|||||||
</ds-space>
|
</ds-space>
|
||||||
<ds-button
|
<ds-button
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:loading="$apollo.loading" primary fullwidth name="submit" type="submit" icon="envelope">
|
:loading="$apollo.loading"
|
||||||
|
primary
|
||||||
|
fullwidth
|
||||||
|
name="submit"
|
||||||
|
type="submit"
|
||||||
|
icon="envelope"
|
||||||
|
>
|
||||||
{{ $t('password-reset.form.submit') }}
|
{{ $t('password-reset.form.submit') }}
|
||||||
</ds-button>
|
</ds-button>
|
||||||
</ds-form>
|
</ds-form>
|
||||||
|
<div v-else>
|
||||||
|
<transition name="ds-transition-fade">
|
||||||
|
<ds-flex centered>
|
||||||
|
<sweetalert-icon icon="success" />
|
||||||
|
</ds-flex>
|
||||||
|
</transition>
|
||||||
|
<ds-text v-html="submitMessage" />
|
||||||
|
</div>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
</ds-card>
|
</ds-card>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
@ -40,33 +56,43 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
import { SweetalertIcon } from 'vue-sweetalert-icons'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
layout: 'default',
|
layout: 'default',
|
||||||
|
components: {
|
||||||
|
SweetalertIcon,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
formData: {
|
formData: {
|
||||||
email: ''
|
email: '',
|
||||||
},
|
},
|
||||||
formSchema: {
|
formSchema: {
|
||||||
email: {
|
email: {
|
||||||
type: 'email',
|
type: 'email',
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('common.validations.email'),
|
message: this.$t('common.validations.email'),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
disabled: true,
|
disabled: true,
|
||||||
|
submitted: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
submitMessage() {
|
||||||
|
const { email } = this.formData
|
||||||
|
return this.$t('password-reset.form.submitted', { email })
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleInput(data) {
|
handleInput() {
|
||||||
this.disabled = true
|
this.disabled = true
|
||||||
},
|
},
|
||||||
handleInputValid(data) {
|
handleInputValid() {
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
},
|
},
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
console.log('handleSubmit')
|
|
||||||
const mutation = gql`
|
const mutation = gql`
|
||||||
mutation($email: String!) {
|
mutation($email: String!) {
|
||||||
requestPasswordReset(email: $email)
|
requestPasswordReset(email: $email)
|
||||||
@ -75,15 +101,12 @@ export default {
|
|||||||
const variables = this.formData
|
const variables = this.formData
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await this.$apollo.mutate({ mutation, variables })
|
await this.$apollo.mutate({ mutation, variables })
|
||||||
this.$toast.success(this.$t('password-reset.form.submitted'))
|
this.submitted = true
|
||||||
this.formData = {
|
|
||||||
email: '',
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.$toast.error(err.message)
|
this.$toast.error(err.message)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user