feat: refs #7702 ask old pass
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
e43ba9b58a
commit
67c2e284ba
|
@ -6,7 +6,10 @@ import VnInput from './VnInput.vue';
|
||||||
import FetchData from '../FetchData.vue';
|
import FetchData from '../FetchData.vue';
|
||||||
import useNotify from 'src/composables/useNotify';
|
import useNotify from 'src/composables/useNotify';
|
||||||
|
|
||||||
const props = defineProps({ submitFn: { type: Function, default: () => {} } });
|
const props = defineProps({
|
||||||
|
submitFn: { type: Function, default: () => {} },
|
||||||
|
askOldPass: { type: Boolean, default: false },
|
||||||
|
});
|
||||||
const emit = defineEmits(['onSubmit']);
|
const emit = defineEmits(['onSubmit']);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
@ -18,8 +21,7 @@ const requirements = ref([]);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
const validate = async () => {
|
const validate = async () => {
|
||||||
const { newPassword, repeatPassword } = passwords.value;
|
const { newPassword, repeatPassword, oldPassword } = passwords.value;
|
||||||
console.log('Validating passwords:', newPassword, repeatPassword);
|
|
||||||
|
|
||||||
if (!newPassword) {
|
if (!newPassword) {
|
||||||
notify(t('You must enter a new password'), 'negative');
|
notify(t('You must enter a new password'), 'negative');
|
||||||
|
@ -29,17 +31,14 @@ const validate = async () => {
|
||||||
notify(t("Passwords don't match"), 'negative');
|
notify(t("Passwords don't match"), 'negative');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
console.log('Calling submitFn with:', newPassword);
|
await props.submitFn(newPassword, oldPassword);
|
||||||
|
|
||||||
await props.submitFn(newPassword);
|
|
||||||
emit('onSubmit');
|
emit('onSubmit');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('submitFn failed:', e);
|
|
||||||
notify('errors.writeRequest', 'negative');
|
notify('errors.writeRequest', 'negative');
|
||||||
} finally {
|
} finally {
|
||||||
console.log('Entering finally block');
|
|
||||||
changePassDialog.value.hide();
|
changePassDialog.value.hide();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +57,7 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
||||||
<QCardSection>
|
<QCardSection>
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
<VnRow class="items-center" style="flex-direction: row">
|
<VnRow class="items-center" style="flex-direction: row">
|
||||||
<span class="text-h6" v-text="t('Change password')" />
|
<span class="text-h6" v-text="t('globals.changePass')" />
|
||||||
<QIcon
|
<QIcon
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
name="close"
|
name="close"
|
||||||
|
@ -71,6 +70,14 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QForm ref="form">
|
<QForm ref="form">
|
||||||
<QCardSection>
|
<QCardSection>
|
||||||
|
<VnInput
|
||||||
|
v-if="props.askOldPass"
|
||||||
|
:label="t('Old password')"
|
||||||
|
v-model="passwords.oldPassword"
|
||||||
|
type="password"
|
||||||
|
:required="true"
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('New password')"
|
:label="t('New password')"
|
||||||
v-model="passwords.newPassword"
|
v-model="passwords.newPassword"
|
||||||
|
@ -122,7 +129,6 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Change password: Cambiar contraseña
|
|
||||||
New password: Nueva contraseña
|
New password: Nueva contraseña
|
||||||
Repeat password: Repetir contraseña
|
Repeat password: Repetir contraseña
|
||||||
You must enter a new password: Debes introducir la nueva contraseña
|
You must enter a new password: Debes introducir la nueva contraseña
|
||||||
|
|
|
@ -300,6 +300,7 @@ globals:
|
||||||
from: From
|
from: From
|
||||||
To: To
|
To: To
|
||||||
stateFk: State
|
stateFk: State
|
||||||
|
changePass: Change password
|
||||||
errors:
|
errors:
|
||||||
statusUnauthorized: Access denied
|
statusUnauthorized: Access denied
|
||||||
statusInternalServerError: An internal server error has ocurred
|
statusInternalServerError: An internal server error has ocurred
|
||||||
|
|
|
@ -304,6 +304,7 @@ globals:
|
||||||
from: Desde
|
from: Desde
|
||||||
To: Hasta
|
To: Hasta
|
||||||
stateFk: Estado
|
stateFk: Estado
|
||||||
|
changePass: Cambiar contraseña
|
||||||
errors:
|
errors:
|
||||||
statusUnauthorized: Acceso denegado
|
statusUnauthorized: Acceso denegado
|
||||||
statusInternalServerError: Ha ocurrido un error interno del servidor
|
statusInternalServerError: Ha ocurrido un error interno del servidor
|
||||||
|
|
|
@ -4,9 +4,12 @@ import { computed, ref, toRefs } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||||
|
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
hasAccount: {
|
hasAccount: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -62,6 +65,19 @@ async function sync() {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<VnChangePassword
|
||||||
|
ref="changePassRef"
|
||||||
|
:ask-old-pass="true"
|
||||||
|
:submit-fn="
|
||||||
|
async (newPassword, oldPassword) => {
|
||||||
|
await axios.patch(`Accounts/change-password`, {
|
||||||
|
userId: entityId,
|
||||||
|
newPassword,
|
||||||
|
oldPassword,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
<VnConfirm
|
<VnConfirm
|
||||||
v-model="showSyncDialog"
|
v-model="showSyncDialog"
|
||||||
:message="t('account.card.actions.sync.message')"
|
:message="t('account.card.actions.sync.message')"
|
||||||
|
@ -92,6 +108,17 @@ async function sync() {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnConfirm>
|
</VnConfirm>
|
||||||
|
<QItem
|
||||||
|
v-if="
|
||||||
|
entityId == account.id &&
|
||||||
|
useAcl().hasAny([{ model: 'Account', props: '*', accessType: 'WRITE' }])
|
||||||
|
"
|
||||||
|
v-ripple
|
||||||
|
clickable
|
||||||
|
@click="$refs.changePassRef.show()"
|
||||||
|
>
|
||||||
|
<QItemSection>{{ t('globals.changePass') }}</QItemSection>
|
||||||
|
</QItem>
|
||||||
<QItem
|
<QItem
|
||||||
v-if="account.hasAccount"
|
v-if="account.hasAccount"
|
||||||
v-ripple
|
v-ripple
|
||||||
|
@ -138,6 +165,5 @@ async function sync() {
|
||||||
<QItem v-ripple clickable @click="showSyncDialog = true">
|
<QItem v-ripple clickable @click="showSyncDialog = true">
|
||||||
<QItemSection>{{ t('account.card.actions.sync.name') }}</QItemSection>
|
<QItemSection>{{ t('account.card.actions.sync.name') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -56,7 +56,7 @@ async function hasCustomerRole() {
|
||||||
</template>
|
</template>
|
||||||
<template #moreActions>
|
<template #moreActions>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('Change password')"
|
:label="t('globals.changePass')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="edit"
|
icon="edit"
|
||||||
:disable="!canChangePassword"
|
:disable="!canChangePassword"
|
||||||
|
@ -81,5 +81,4 @@ es:
|
||||||
User: Usuario
|
User: Usuario
|
||||||
Recovery email: Correo de recuperacion
|
Recovery email: Correo de recuperacion
|
||||||
This email is used for user to regain access their account: Este correo electrónico se usa para que el usuario recupere el acceso a su cuenta
|
This email is used for user to regain access their account: Este correo electrónico se usa para que el usuario recupere el acceso a su cuenta
|
||||||
Change password: Cambiar contraseña
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -88,7 +88,7 @@ const handlePhotoUpdated = (evt = false) => {
|
||||||
@click="$refs.changePassRef.show"
|
@click="$refs.changePassRef.show"
|
||||||
>
|
>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
{{ t('Change password') }}
|
{{ t('globals.changePass') }}
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
|
@ -209,5 +209,4 @@ const handlePhotoUpdated = (evt = false) => {
|
||||||
es:
|
es:
|
||||||
Click to allow the user to be disabled: Marcar para deshabilitar
|
Click to allow the user to be disabled: Marcar para deshabilitar
|
||||||
Click to exclude the user from getting disabled: Marcar para no deshabilitar
|
Click to exclude the user from getting disabled: Marcar para no deshabilitar
|
||||||
Change password: Cambiar contraseña
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue