Skip to content

Commit

Permalink
Merge pull request #336 from codescalers/development_1.1_password_con…
Browse files Browse the repository at this point in the history
…firmation

Add confirm password
  • Loading branch information
zaelgohary authored Feb 1, 2024
2 parents ac1459a + 78b7616 commit e074c2c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 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
4 changes: 2 additions & 2 deletions server/cshr/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def put(self, request: Request) -> Response:
request.user.password = new_password
request.user.save()
return CustomResponse.success(message="Success updated password")
return CustomResponse.unauthorized()
return CustomResponse.unauthorized(message="Incorrect password. Please ensure that the password provided is accurate.")
return CustomResponse.bad_request(
message="Please make sure that you entered a valid data",
message="Please make sure that you entered a valid data.",
error=serializer.errors,
)

0 comments on commit e074c2c

Please sign in to comment.