- now authenticated user can change password with check of old password and password confirmination
Some checks failed
CI Pipeline / japa-tests (push) Failing after 52s

- cchanged route app.dashboard to apps.dashboard
- add editor and reviewer relation to Dataset.ts
- added personal menu in asideMenu
- added Approve.vue for editor
- show warning in Index.vue  (editor), if no dataset is loaded
- user Receive.vue without inertia helper form
- npm updates
- added routes in routes.ts
This commit is contained in:
Kaimbacher 2023-12-12 15:22:25 +01:00
parent 0d51002903
commit ae0c471e93
14 changed files with 733 additions and 408 deletions

View file

@ -4,9 +4,9 @@ import { useForm } from '@inertiajs/vue3';
// import { reactive } from 'vue';
import {
mdiAccount,
mdiAccountCircle,
// mdiAccountCircle,
mdiLock,
mdiMail,
// mdiMail,
mdiAsterisk,
mdiFormTextboxPassword,
mdiArrowLeftBoldOutline,
@ -24,8 +24,12 @@ import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
import { stardust } from '@eidellev/adonis-stardust/client';
// import { Inertia } from '@inertiajs/inertia';
import { computed, Ref } from 'vue';
import { usePage } from '@inertiajs/vue3';
import FormValidationErrors from '@/Components/FormValidationErrors.vue';
const props = defineProps({
defineProps({
// user will be returned from controller action
user: {
type: Object,
@ -37,13 +41,13 @@ const props = defineProps({
},
});
const profileForm = useForm({
login: props.user.login,
email: props.user.email,
});
const profileSubmit = async () => {
await profileForm.post(stardust.route('admin.account.info.store', [props.user.id]));
};
// const profileForm = useForm({
// login: props.user.login,
// email: props.user.email,
// });
// const profileSubmit = async () => {
// await profileForm.post(stardust.route('admin.account.info.store', [props.user.id]));
// };
const passwordForm = useForm({
old_password: '',
@ -51,38 +55,38 @@ const passwordForm = useForm({
confirm_password: '',
});
const passwordSubmit = async () => {
await passwordForm.post(stardust.route('admin.account.info.store'), {
await passwordForm.post(stardust.route('account.info.store'), {
preserveScroll: true,
onSuccess: (resp) => {
console.log(resp);
onSuccess: () => {
// console.log(resp);
passwordForm.reset();
},
});
};
const flash: Ref<any> = computed(() => {
return usePage().props.flash;
});
</script>
<template>
<LayoutAuthenticated>
<SectionMain>
<SectionTitleLineWithButton :icon="mdiAccount" title="Profile" main>
<BaseButton
:route-name="stardust.route('dashboard')"
:icon="mdiArrowLeftBoldOutline"
label="Back"
color="white"
rounded-full
small
/>
<BaseButton :route-name="stardust.route('dashboard')" :icon="mdiArrowLeftBoldOutline" label="Back"
color="white" rounded-full small />
</SectionTitleLineWithButton>
<!-- <NotificationBar v-if="$page.props.flash.message" color="success" :icon="mdiAlertBoxOutline">
{{ $page.props.flash.message }}
</NotificationBar> -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- <div class="grid grid-cols-1 lg:grid-cols-2 gap-6"> -->
<div class="grid grid-cols-1 lg:grid-cols-1 gap-6">
<!-- password form -->
<!-- <CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileForm.post(route('admin.account.info.store'))"> -->
<CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileSubmit()">
<!-- <CardBox title="Edit Profile" :icon="mdiAccountCircle" form @submit.prevent="profileSubmit()">
<FormField label="Login" help="Required. Your login name" :class="{ 'text-red-400': errors.login }">
<FormControl v-model="profileForm.login" v-bind:icon="mdiAccount" name="login" required :error="errors.login">
<div class="text-red-400 text-sm" v-if="errors.login">
@ -103,77 +107,59 @@ const passwordSubmit = async () => {
<BaseButton color="info" type="submit" label="Submit" />
</BaseButtons>
</template>
</CardBox>
</CardBox> -->
<!-- password form -->
<!-- <CardBox title="Change Password" :icon="mdiLock" form @submit.prevent="passwordForm.post(route('admin.account.password.store'), {
preserveScroll: true,
onSuccess: () => passwordForm.reset(),
})
"> -->
<CardBox title="Change Password" :icon="mdiLock" form @submit.prevent="passwordSubmit()">
<FormField
label="Current password"
help="Required. Your current password"
:class="{ 'text-red-400': passwordForm.errors.old_password }"
>
<FormControl
v-model="passwordForm.old_password"
:icon="mdiAsterisk"
name="old_password"
type="password"
required
:error="passwordForm.errors.old_password"
>
}) "> -->
<CardBox id="passwordForm" title="Change Password" :icon="mdiLock" form @submit.prevent="passwordSubmit()">
<FormValidationErrors v-bind:errors="errors" />
<FormField label="Current password" help="Required. Your current password"
:class="{ 'text-red-400': passwordForm.errors.old_password }">
<FormControl v-model="passwordForm.old_password" :icon="mdiAsterisk" name="old_password"
type="password" required :error="passwordForm.errors.old_password">
<div class="text-red-400 text-sm" v-if="passwordForm.errors.old_password">
{{ passwordForm.errors.old_password }}
</div>
</FormControl>
</FormField>
<BaseDivider />
<FormField
label="New password"
help="Required. New password"
:class="{ 'text-red-400': passwordForm.errors.new_password }"
>
<FormControl
v-model="passwordForm.new_password"
:icon="mdiFormTextboxPassword"
name="new_password"
type="password"
required
:error="passwordForm.errors.new_password"
>
<FormField label="New password" help="Required. New password"
:class="{ 'text-red-400': passwordForm.errors.new_password }">
<FormControl v-model="passwordForm.new_password" :icon="mdiFormTextboxPassword" name="new_password"
type="password" required :error="passwordForm.errors.new_password">
<div class="text-red-400 text-sm" v-if="passwordForm.errors.new_password">
{{ passwordForm.errors.new_password }}
</div>
</FormControl>
</FormField>
<FormField
label="Confirm password"
help="Required. New password one more time"
:class="{ 'text-red-400': passwordForm.errors.confirm_password }"
>
<FormControl
v-model="passwordForm.confirm_password"
:icon="mdiFormTextboxPassword"
name="confirm_password"
type="password"
required
:error="passwordForm.errors.confirm_password"
>
<FormField label="Confirm password" help="Required. New password one more time"
:class="{ 'text-red-400': passwordForm.errors.confirm_password }">
<FormControl v-model="passwordForm.confirm_password" :icon="mdiFormTextboxPassword"
name="confirm_password" type="password" required :error="passwordForm.errors.confirm_password">
<div class="text-red-400 text-sm" v-if="passwordForm.errors.confirm_password">
{{ passwordForm.errors.confirm_password }}
</div>
</FormControl>
</FormField>
<div v-if="flash && flash.message" class="flex flex-col mt-6 animate-fade-in">
<div class="bg-yellow-500 border-l-4 border-orange-400 text-white p-4" role="alert">
<p class="font-bold">Be Warned</p>
<p>{{ flash.message }}</p>
</div>
</div>
<BaseDivider />
<template #footer>
<BaseButtons>
<BaseButton type="submit" color="info" label="Submit" />
<BaseButton type="submit" color="info" label="Change password" />
</BaseButtons>
</template>
</CardBox>