133058576SYoshie Muranaka<template> 2932aff93SDerick Montague <div class="change-password-container"> 333058576SYoshie Muranaka <alert variant="danger" class="mb-4"> 42c98b095SYoshie Muranaka <p v-if="changePasswordError"> 52c98b095SYoshie Muranaka {{ $t('pageChangePassword.changePasswordError') }} 62c98b095SYoshie Muranaka </p> 72c98b095SYoshie Muranaka <p v-else>{{ $t('pageChangePassword.changePasswordAlertMessage') }}</p> 833058576SYoshie Muranaka </alert> 9932aff93SDerick Montague <div class="change-password__form-container"> 1033058576SYoshie Muranaka <dl> 1133058576SYoshie Muranaka <dt>{{ $t('pageChangePassword.username') }}</dt> 1233058576SYoshie Muranaka <dd>{{ username }}</dd> 1333058576SYoshie Muranaka </dl> 1433058576SYoshie Muranaka <b-form novalidate @submit.prevent="changePassword"> 1533058576SYoshie Muranaka <b-form-group 1633058576SYoshie Muranaka label-for="password" 1733058576SYoshie Muranaka :label="$t('pageChangePassword.newPassword')" 1833058576SYoshie Muranaka > 1933058576SYoshie Muranaka <input-password-toggle> 2033058576SYoshie Muranaka <b-form-input 2133058576SYoshie Muranaka id="password" 2233058576SYoshie Muranaka v-model="form.password" 2333058576SYoshie Muranaka autofocus="autofocus" 2433058576SYoshie Muranaka type="password" 25de23ea23SSurya V :state="getValidationState(v$.form.password)" 265ea16782SDixsie Wolmers class="form-control-with-button" 27de23ea23SSurya V @change="v$.form.password.$touch()" 2833058576SYoshie Muranaka > 2933058576SYoshie Muranaka </b-form-input> 3033058576SYoshie Muranaka <b-form-invalid-feedback role="alert"> 31*69be824aSSurya Venkatesan <template v-if="v$.form.password.required.$invalid"> 3233058576SYoshie Muranaka {{ $t('global.form.fieldRequired') }} 3333058576SYoshie Muranaka </template> 3433058576SYoshie Muranaka </b-form-invalid-feedback> 3533058576SYoshie Muranaka </input-password-toggle> 3633058576SYoshie Muranaka </b-form-group> 3733058576SYoshie Muranaka <b-form-group 3833058576SYoshie Muranaka label-for="password-confirm" 3933058576SYoshie Muranaka :label="$t('pageChangePassword.confirmNewPassword')" 4033058576SYoshie Muranaka > 4133058576SYoshie Muranaka <input-password-toggle> 4233058576SYoshie Muranaka <b-form-input 4333058576SYoshie Muranaka id="password-confirm" 4433058576SYoshie Muranaka v-model="form.passwordConfirm" 4533058576SYoshie Muranaka type="password" 46de23ea23SSurya V :state="getValidationState(v$.form.passwordConfirm)" 475ea16782SDixsie Wolmers class="form-control-with-button" 48de23ea23SSurya V @change="v$.form.passwordConfirm.$touch()" 4933058576SYoshie Muranaka > 5033058576SYoshie Muranaka </b-form-input> 5133058576SYoshie Muranaka <b-form-invalid-feedback role="alert"> 52*69be824aSSurya Venkatesan <template v-if="v$.form.passwordConfirm.required.$invalid"> 5333058576SYoshie Muranaka {{ $t('global.form.fieldRequired') }} 5433058576SYoshie Muranaka </template> 55*69be824aSSurya Venkatesan <template 56*69be824aSSurya Venkatesan v-else-if="v$.form.passwordConfirm.sameAsPassword.$invalid" 57*69be824aSSurya Venkatesan > 5833058576SYoshie Muranaka {{ $t('global.form.passwordsDoNotMatch') }} 5933058576SYoshie Muranaka </template> 6033058576SYoshie Muranaka </b-form-invalid-feedback> 6133058576SYoshie Muranaka </input-password-toggle> 6233058576SYoshie Muranaka </b-form-group> 6333058576SYoshie Muranaka <div class="text-right"> 642c98b095SYoshie Muranaka <b-button type="button" variant="link" @click="goBack"> 6533058576SYoshie Muranaka {{ $t('pageChangePassword.goBack') }} 6633058576SYoshie Muranaka </b-button> 6733058576SYoshie Muranaka <b-button type="submit" variant="primary"> 6833058576SYoshie Muranaka {{ $t('pageChangePassword.changePassword') }} 6933058576SYoshie Muranaka </b-button> 7033058576SYoshie Muranaka </div> 7133058576SYoshie Muranaka </b-form> 7233058576SYoshie Muranaka </div> 73932aff93SDerick Montague </div> 7433058576SYoshie Muranaka</template> 7533058576SYoshie Muranaka 7633058576SYoshie Muranaka<script> 777d6b44cbSEd Tanousimport { required, sameAs } from '@vuelidate/validators'; 7833058576SYoshie Muranakaimport Alert from '@/components/Global/Alert'; 7933058576SYoshie Muranakaimport VuelidateMixin from '@/components/Mixins/VuelidateMixin'; 8033058576SYoshie Muranakaimport InputPasswordToggle from '@/components/Global/InputPasswordToggle'; 812c98b095SYoshie Muranakaimport BVToastMixin from '@/components/Mixins/BVToastMixin'; 827d6b44cbSEd Tanousimport { useVuelidate } from '@vuelidate/core'; 83de23ea23SSurya Vimport { useI18n } from 'vue-i18n'; 8433058576SYoshie Muranaka 8533058576SYoshie Muranakaexport default { 8633058576SYoshie Muranaka name: 'ChangePassword', 8733058576SYoshie Muranaka components: { Alert, InputPasswordToggle }, 882c98b095SYoshie Muranaka mixins: [VuelidateMixin, BVToastMixin], 897d6b44cbSEd Tanous setup() { 907d6b44cbSEd Tanous return { 917d6b44cbSEd Tanous v$: useVuelidate(), 927d6b44cbSEd Tanous }; 937d6b44cbSEd Tanous }, 9433058576SYoshie Muranaka data() { 9533058576SYoshie Muranaka return { 96de23ea23SSurya V $t: useI18n().t, 9733058576SYoshie Muranaka form: { 9833058576SYoshie Muranaka password: null, 99602e98aaSDerick Montague passwordConfirm: null, 10033058576SYoshie Muranaka }, 1012c98b095SYoshie Muranaka username: this.$store.getters['global/username'], 102602e98aaSDerick Montague changePasswordError: false, 10333058576SYoshie Muranaka }; 10433058576SYoshie Muranaka }, 10533058576SYoshie Muranaka validations() { 10633058576SYoshie Muranaka return { 10733058576SYoshie Muranaka form: { 10833058576SYoshie Muranaka password: { required }, 10933058576SYoshie Muranaka passwordConfirm: { 11033058576SYoshie Muranaka required, 111602e98aaSDerick Montague sameAsPassword: sameAs('password'), 112602e98aaSDerick Montague }, 113602e98aaSDerick Montague }, 11433058576SYoshie Muranaka }; 11533058576SYoshie Muranaka }, 11633058576SYoshie Muranaka methods: { 11733058576SYoshie Muranaka goBack() { 1182c98b095SYoshie Muranaka // Remove session created if navigating back to the Login page 1192c98b095SYoshie Muranaka this.$store.dispatch('authentication/logout'); 12033058576SYoshie Muranaka }, 12133058576SYoshie Muranaka changePassword() { 122de23ea23SSurya V this.v$.$touch(); 123de23ea23SSurya V if (this.v$.$invalid) return; 1242c98b095SYoshie Muranaka let data = { 1252c98b095SYoshie Muranaka originalUsername: this.username, 126602e98aaSDerick Montague password: this.form.password, 1272c98b095SYoshie Muranaka }; 1282c98b095SYoshie Muranaka 1292c98b095SYoshie Muranaka this.$store 130b440616cSSandeepa Singh .dispatch('userManagement/updateUser', data) 1312c98b095SYoshie Muranaka .then(() => this.$router.push('/')) 1322c98b095SYoshie Muranaka .catch(() => (this.changePasswordError = true)); 133602e98aaSDerick Montague }, 134602e98aaSDerick Montague }, 13533058576SYoshie Muranaka}; 13633058576SYoshie Muranaka</script> 13733058576SYoshie Muranaka 13833058576SYoshie Muranaka<style lang="scss" scoped> 1397d6b44cbSEd Tanous@import '@/assets/styles/bmc/helpers/_index.scss'; 1407d6b44cbSEd Tanous@import '@/assets/styles/bootstrap/_helpers.scss'; 1417d6b44cbSEd Tanous 1427d6b44cbSEd Tanous@import '@/assets/styles/bootstrap/_helpers.scss'; 1437d6b44cbSEd Tanous 144932aff93SDerick Montague.change-password__form-container { 145932aff93SDerick Montague @include media-breakpoint-up('md') { 14633058576SYoshie Muranaka max-width: 360px; 14733058576SYoshie Muranaka } 148932aff93SDerick Montague} 14933058576SYoshie Muranaka</style> 150