This commit is contained in:
@@ -339,8 +339,10 @@ export default {
|
||||
toPath = undefined;
|
||||
}
|
||||
|
||||
let isReset = toPath && toPath.includes("home-reset");
|
||||
|
||||
//redirect to login if not authenticated
|
||||
if (!vm.$store.state.authenticated) {
|
||||
if (!vm.$store.state.authenticated && !isReset) {
|
||||
//If a direct open path was being used but user is not logged in this will catch it
|
||||
//otherwise they will just go on to that path directly
|
||||
|
||||
|
||||
@@ -127,14 +127,12 @@ export default new Router({
|
||||
/* webpackChunkName: "ay-common" */ "./views/home-user-settings.vue"
|
||||
)
|
||||
},
|
||||
// {
|
||||
// path: "/home-translation",
|
||||
// name: "home-translation",
|
||||
// component: () =>
|
||||
// import(
|
||||
// /* webpackChunkName: "ay-common" */ "./views/home-translation.vue"
|
||||
// )
|
||||
// },
|
||||
{
|
||||
path: "/home-reset",
|
||||
name: "home-reset",
|
||||
component: () =>
|
||||
import(/* webpackChunkName: "ay-common" */ "./views/home-reset.vue")
|
||||
},
|
||||
{
|
||||
path: "/home-password",
|
||||
name: "home-password",
|
||||
|
||||
@@ -855,7 +855,25 @@ export default {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
}
|
||||
}
|
||||
},
|
||||
async sendResetCode() {
|
||||
let vm = this;
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
try {
|
||||
let res = await window.$gz.api.post(
|
||||
`auth/request-reset-password/${vm.obj.id}`,
|
||||
null
|
||||
);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
}
|
||||
}
|
||||
|
||||
//------more above here
|
||||
}
|
||||
};
|
||||
|
||||
@@ -923,6 +941,9 @@ async function clickHandler(menuItem) {
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "sendreset":
|
||||
m.vm.sendResetCode();
|
||||
break;
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
@@ -1007,12 +1028,23 @@ function generateMenu(vm) {
|
||||
});
|
||||
}
|
||||
|
||||
menuOptions.menuItems.push({
|
||||
title: "DirectNotification",
|
||||
icon: "$ayiCommentAlt",
|
||||
key: FORM_KEY + ":directnotify",
|
||||
vm: vm
|
||||
});
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
menuOptions.menuItems.push({
|
||||
title: "DirectNotification",
|
||||
icon: "$ayiCommentAlt",
|
||||
key: FORM_KEY + ":directnotify",
|
||||
vm: vm
|
||||
});
|
||||
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: "SendPasswordResetCode",
|
||||
icon: null,
|
||||
key: FORM_KEY + ":sendreset",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
|
||||
113
ayanova/src/views/home-reset.vue
Normal file
113
ayanova/src/views/home-reset.vue
Normal file
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<v-form ref="form">
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<v-text-field
|
||||
v-model="obj.newPassword"
|
||||
:readonly="formState.readOnly"
|
||||
:append-outer-icon="reveal ? '$ayiEye' : '$ayiEyeSlash'"
|
||||
prepend-icon="$ayiKey"
|
||||
:label="$ay.t('NewPassword')"
|
||||
:type="reveal ? 'text' : 'password'"
|
||||
:rules="[form().required(this, 'newPassword')]"
|
||||
:error-messages="form().serverErrors(this, 'newPassword')"
|
||||
ref="newPassword"
|
||||
@input="fieldValueChanged('newPassword')"
|
||||
@click:append-outer="reveal = !reveal"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12">
|
||||
<v-text-field
|
||||
v-model="obj.confirmPassword"
|
||||
:readonly="formState.readOnly"
|
||||
:append-outer-icon="reveal ? '$ayiEye' : '$ayiEyeSlash'"
|
||||
prepend-icon="$ayiKey"
|
||||
:label="$ay.t('ConfirmPassword')"
|
||||
:type="reveal ? 'text' : 'password'"
|
||||
:rules="[
|
||||
form().required(this, 'confirmPassword'),
|
||||
form().confirmMatch(this, 'newPassword', 'confirmPassword')
|
||||
]"
|
||||
:error-messages="form().serverErrors(this, 'confirmPassword')"
|
||||
ref="confirmPassword"
|
||||
@input="fieldValueChanged('confirmPassword')"
|
||||
@click:append-outer="reveal = !reveal"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" md="7" mt-1 mb-5>
|
||||
<v-btn color="primary" v-on:click="login()" value="LOGIN">
|
||||
<v-icon>$ayiSignIn</v-icon>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/* Xeslint-disable */
|
||||
export default {
|
||||
async created() {},
|
||||
data() {
|
||||
return {
|
||||
obj: {
|
||||
newPassword: null,
|
||||
confirmPassword: null,
|
||||
passwordResetCode: null
|
||||
},
|
||||
reveal: true,
|
||||
formState: {
|
||||
ready: true,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: false,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
translation() {
|
||||
return window.$gz.translation;
|
||||
},
|
||||
form() {
|
||||
return window.$gz.form;
|
||||
},
|
||||
fieldValueChanged(ref) {
|
||||
if (!this.formState.loading && !this.formState.readOnly) {
|
||||
window.$gz.form.fieldValueChanged(this, ref);
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
let vm = this;
|
||||
if (vm.canSave) {
|
||||
vm.formState.loading = true;
|
||||
|
||||
let url = "auth/reset-password";
|
||||
|
||||
try {
|
||||
let res = await window.$gz.api.upsert(url, {
|
||||
PasswordResetCode: obj.passwordResetCode,
|
||||
Password: obj.confirmPassword
|
||||
});
|
||||
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
vm.$router.push({
|
||||
name: "login"
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
} finally {
|
||||
vm.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user