Skip to content

Commit

Permalink
Add confirm password
Browse files Browse the repository at this point in the history
  • Loading branch information
zaelgohary committed Feb 1, 2024
1 parent 1071ef1 commit c0f6884
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions client/src/views/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,35 @@
<v-col cols="12">
<v-text-field
v-model="old_password"
:append-inner-icon="show_old ? 'mdi-eye' : 'mdi-eye-off'"
:rules="passwordRules"
type="text"
:type="show_old ? 'text' : 'password'"
label="Old Password"
@click:append-inner="show_old = !show_old"
></v-text-field>
</v-col>

<v-col cols="12">
<v-text-field
v-model="new_password"
:rules="passwordRules"
type="text"
:append-inner-icon="show_new ? 'mdi-eye' : 'mdi-eye-off'"
:rules="[...passwordRules, confirmPassword]"
:type="show_new ? 'text' : 'password'"
label="New Password"
@click:append-inner="show_new = !show_new"
@input="validateForm"
></v-text-field>
</v-col>

<v-col cols="12">
<v-text-field
v-model="confirm_password"
:append-inner-icon="show_confirm ? 'mdi-eye' : 'mdi-eye-off'"
:rules="[...passwordRules, confirmPassword]"
:type="show_confirm ? 'text' : 'password'"
label="Confirm Password"
@click:append-inner="show_confirm = !show_confirm"
@input="validateForm"
></v-text-field>
</v-col>

Expand Down Expand Up @@ -49,8 +66,12 @@ import { useAsyncState } from '@vueuse/core'
export default defineComponent({
setup() {
const form = ref()
const show_old = ref<boolean>(false)
const show_new = ref<boolean>(false)
const show_confirm = ref<boolean>(false)
const old_password = ref<string>('')
const new_password = ref<string>('')
const confirm_password = ref<string>('')
const { execute, isLoading } = useAsyncState(
async () => {
Expand All @@ -63,13 +84,25 @@ export default defineComponent({
{ immediate: false }
)
const confirmPassword = () => new_password.value == confirm_password.value || "Passwords should match."
const validateForm = () => {
form.value?.validate()
}
return {
form,
show_old,
show_new,
old_password,
new_password,
show_confirm,
confirm_password,
passwordRules,
isLoading,
execute
execute,
confirmPassword,
validateForm
}
}
})
Expand Down

0 comments on commit c0f6884

Please sign in to comment.