summaryrefslogtreecommitdiff
path: root/pse-dashboard/src/views/ResetPasswordView.vue
blob: a617af33c42a0ec9dbcf936bf73875b59068ae62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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>