@@ -52,6 +52,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import useYup from '@/composables/useYup'
|
||||
import useAuth from '@/composables/useAuth'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
@@ -63,15 +64,16 @@ import AuthShell from '@/features/auth/components/AuthShell.vue'
|
||||
import { useResetPasswordMutation } from '@/services/query/auth'
|
||||
import AuthHeading from '@/features/auth/components/AuthHeading.vue'
|
||||
import AuthCopyright from '@/features/auth/components/AuthCopyright.vue'
|
||||
import { useRedirectAfterLogin } from '@/features/auth/composables/useRedirectAfterLogin'
|
||||
import { usePasswordReset } from '@/features/auth/composables/usePasswordReset'
|
||||
|
||||
const { user, applySession } = useAuth()
|
||||
const redirectAfterLogin = useRedirectAfterLogin()
|
||||
const { user } = useAuth()
|
||||
const { phone: resetPhone, token: resetToken, clearResetTicket } = usePasswordReset()
|
||||
const router = useRouter()
|
||||
|
||||
const schema = resetPasswordSchema
|
||||
|
||||
const form = ref({
|
||||
phone: user.value?.phone || '',
|
||||
phone: resetPhone.value || user.value?.phone || '',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
})
|
||||
@@ -82,9 +84,14 @@ const resetMutation = useResetPasswordMutation()
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
const response = await resetMutation.mutateAsync(payload)
|
||||
applySession(response?.data ?? response)
|
||||
redirectAfterLogin()
|
||||
await resetMutation.mutateAsync({
|
||||
phone: form.value.phone,
|
||||
token: resetToken.value,
|
||||
password: payload.password,
|
||||
passwordConfirmation: payload.passwordConfirmation,
|
||||
})
|
||||
clearResetTicket()
|
||||
router.push({ name: 'login' })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user