diff options
author | Orangerot <purple@orangerot.dev> | 2024-06-19 00:14:49 +0200 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2024-06-27 12:11:14 +0200 |
commit | 5b8851b6c268d0e93c158908fbfae9f8473db5ff (patch) | |
tree | 7010eb85d86fa2da06ea4ffbcdb01a685d502ae8 /pse-dashboard/src/views/ResetPasswordView.vue |
Diffstat (limited to 'pse-dashboard/src/views/ResetPasswordView.vue')
-rw-r--r-- | pse-dashboard/src/views/ResetPasswordView.vue | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/pse-dashboard/src/views/ResetPasswordView.vue b/pse-dashboard/src/views/ResetPasswordView.vue new file mode 100644 index 0000000..a617af3 --- /dev/null +++ b/pse-dashboard/src/views/ResetPasswordView.vue @@ -0,0 +1,72 @@ +<script setup> +import { FormLayout, PasswordValidator } from '@/components' +import { ref } from 'vue' +import { useLogger } from '@/logger.js' +import { resetPassword } from '@/api/pse-squared.js' +import router from '@/router.js'; + +const props = defineProps({ + token: { + type: String, + default: "" + }, + username: { + type: String, + default: "" + } +}); + +const { passwordRequirements, passwordReset } = useLogger(); + +const passwordModel = ref(null); + +async function formResetPassword() { + if(!passwordModel.value.valid) { + // log.append({type: "info", message: "Password requirements are not met"}) + passwordRequirements(); + return; + } + + try { + await resetPassword({ + username: props.username, + password: passwordModel.value.password, + token: props.token + }); + + passwordReset(); + router.push("/login"); + } catch (err) {} +} + +</script> +<template> + <FormLayout> + <form @submit.prevent="formResetPassword"> + <!-- Text über Texteingabefeld --> + <h1 class="h3 mb-3 fw-normal"> + {{ $t("message.setNewPassword") }} + </h1> + + <!-- Passwort-Validierungs-Komponente --> + <PasswordValidator v-model="passwordModel" /> + + <!-- Absende Knopf für E-Mail-Adresse --> + <button + type="submit" + class="w-100 btn btn-lg btn-primary" + > + {{ $t("message.send") }} + </button> + + <!-- Zurück zur Anmeldung --> + <router-link to="/"> + <button class="w-100 btn btn-lg btn-secondary mt-2"> + {{ $t("message.close") }} + </button> + </router-link> + </form> + </FormLayout> +</template> +<style scoped> +</style> |