Handle passwordReset response on reset page

This commit is contained in:
Robert Schäfer 2019-06-18 22:48:53 +02:00
parent 506fe0fe94
commit cc26d0be94
3 changed files with 14 additions and 7 deletions

View File

@ -80,7 +80,7 @@ describe('VerifyCode ', () => {
beforeEach(jest.runAllTimers)
it('emits `change-password-sucess`', () => {
expect(wrapper.emitted('change-password-result')).toEqual([['success']])
expect(wrapper.emitted('passwordResetResponse')).toEqual([['success']])
})
})
})

View File

@ -168,7 +168,9 @@ export default {
data: { resetPassword },
} = await this.$apollo.mutate({ mutation, variables })
this.changePasswordResult = resetPassword ? 'success' : 'error'
this.$emit('change-password-result', this.changePasswordResult)
setTimeout(() => {
this.$emit('passwordResetResponse', this.changePasswordResult)
}, 3000)
this.verification.formData = {
code: '',
email: '',

View File

@ -3,8 +3,8 @@
<ds-flex>
<ds-flex-item :width="{ base: '100%' }" centered>
<ds-space style="text-align: center;" margin-top="small" margin-bottom="xxx-small" centered>
<password-reset @handleSubmitted="handleSubmitted" v-if="!submitted" />
<verify-code v-else />
<password-reset @handleSubmitted="handlePasswordResetRequested" v-if="!passwordResetRequested" />
<verify-code v-else @passwordResetResponse="handlePasswordResetResponse" />
</ds-space>
</ds-flex-item>
</ds-flex>
@ -19,7 +19,7 @@ export default {
layout: 'default',
data() {
return {
submitted: false,
passwordResetRequested: false
}
},
components: {
@ -27,8 +27,13 @@ export default {
VerifyCode,
},
methods: {
handleSubmitted() {
this.submitted = true
handlePasswordResetRequested() {
this.passwordResetRequested = true
},
handlePasswordResetResponse(response) {
if (response === 'success'){
this.$router.push('login')
}
},
},
}