client: fix password change input

The TS rewrite dropped the form that was expected to be passed
as props.
That lead to the password change being borked, as the fields
were always set to "null".
We don't need a form, can just use refs here.
This commit is contained in:
Reto Brunner 2023-05-23 08:18:20 +02:00
parent e05871fd2f
commit 8f08cf3d0b

View File

@ -15,6 +15,7 @@
<RevealPassword v-slot:default="slotProps"> <RevealPassword v-slot:default="slotProps">
<input <input
id="current-password" id="current-password"
v-model="old_password"
autocomplete="current-password" autocomplete="current-password"
:type="slotProps.isVisible ? 'text' : 'password'" :type="slotProps.isVisible ? 'text' : 'password'"
name="old_password" name="old_password"
@ -28,6 +29,7 @@
<RevealPassword v-slot:default="slotProps"> <RevealPassword v-slot:default="slotProps">
<input <input
id="new-password" id="new-password"
v-model="new_password"
:type="slotProps.isVisible ? 'text' : 'password'" :type="slotProps.isVisible ? 'text' : 'password'"
name="new_password" name="new_password"
autocomplete="new-password" autocomplete="new-password"
@ -41,6 +43,7 @@
<RevealPassword v-slot:default="slotProps"> <RevealPassword v-slot:default="slotProps">
<input <input
id="new-password-verify" id="new-password-verify"
v-model="verify_password"
:type="slotProps.isVisible ? 'text' : 'password'" :type="slotProps.isVisible ? 'text' : 'password'"
name="verify_password" name="verify_password"
autocomplete="new-password" autocomplete="new-password"
@ -111,13 +114,7 @@ export default defineComponent({
RevealPassword, RevealPassword,
Session, Session,
}, },
props: { setup() {
settingsForm: {
type: Object as PropType<HTMLFormElement>,
required: true,
},
},
setup(props) {
const store = useStore(); const store = useStore();
const passwordErrors = { const passwordErrors = {
@ -132,6 +129,10 @@ export default defineComponent({
error: keyof typeof passwordErrors; error: keyof typeof passwordErrors;
}>(); }>();
const old_password = ref("");
const new_password = ref("");
const verify_password = ref("");
const currentSession = computed(() => { const currentSession = computed(() => {
return store.state.sessions.find((item) => item.current); return store.state.sessions.find((item) => item.current);
}); });
@ -149,12 +150,10 @@ export default defineComponent({
}); });
const changePassword = () => { const changePassword = () => {
const allFields = new FormData(props.settingsForm);
const data = { const data = {
old_password: allFields.get("old_password"), old_password: old_password.value,
new_password: allFields.get("new_password"), new_password: new_password.value,
verify_password: allFields.get("verify_password"), verify_password: verify_password.value,
}; };
if (!data.old_password || !data.new_password || !data.verify_password) { if (!data.old_password || !data.new_password || !data.verify_password) {
@ -189,6 +188,9 @@ export default defineComponent({
activeSessions, activeSessions,
otherSessions, otherSessions,
changePassword, changePassword,
old_password,
new_password,
verify_password,
}; };
}, },
}); });