1b1f559f0SSukanya Pandey<template> 2b1f559f0SSukanya Pandey <b-container fluid="xl"> 3b1f559f0SSukanya Pandey <page-title /> 4b1f559f0SSukanya Pandey 5b1f559f0SSukanya Pandey <b-row> 6b1f559f0SSukanya Pandey <b-col md="8" lg="8" xl="6"> 7b1f559f0SSukanya Pandey <page-section :section-title="$t('profileSettings.profileInfoTitle')"> 8b1f559f0SSukanya Pandey <dl> 9b1f559f0SSukanya Pandey <dt>{{ $t('profileSettings.username') }}</dt> 10b1f559f0SSukanya Pandey <dd> 11b1f559f0SSukanya Pandey {{ username }} 12b1f559f0SSukanya Pandey </dd> 13b1f559f0SSukanya Pandey </dl> 14b1f559f0SSukanya Pandey </page-section> 15b1f559f0SSukanya Pandey </b-col> 16b1f559f0SSukanya Pandey </b-row> 17b1f559f0SSukanya Pandey 18b1f559f0SSukanya Pandey <b-form @submit.prevent="submitForm"> 19b1f559f0SSukanya Pandey <b-row> 20b1f559f0SSukanya Pandey <b-col sm="8" md="6" xl="3"> 21b1f559f0SSukanya Pandey <page-section :section-title="$t('profileSettings.changePassword')"> 22b1f559f0SSukanya Pandey <b-form-group 23b1f559f0SSukanya Pandey id="input-group-1" 24b1f559f0SSukanya Pandey :label="$t('profileSettings.newPassword')" 25b1f559f0SSukanya Pandey label-for="input-1" 26b1f559f0SSukanya Pandey > 27b1f559f0SSukanya Pandey <b-form-text id="password-help-block"> 28b1f559f0SSukanya Pandey {{ 29b1f559f0SSukanya Pandey $t('pageLocalUserManagement.modal.passwordMustBeBetween', { 30b1f559f0SSukanya Pandey min: passwordRequirements.minLength, 31b1f559f0SSukanya Pandey max: passwordRequirements.maxLength 32b1f559f0SSukanya Pandey }) 33b1f559f0SSukanya Pandey }} 34b1f559f0SSukanya Pandey </b-form-text> 35b1f559f0SSukanya Pandey <input-password-toggle> 36b1f559f0SSukanya Pandey <b-form-input 37b1f559f0SSukanya Pandey id="password" 38b1f559f0SSukanya Pandey v-model="form.newPassword" 39b1f559f0SSukanya Pandey type="password" 40b1f559f0SSukanya Pandey aria-describedby="password-help-block" 41b1f559f0SSukanya Pandey :state="getValidationState($v.form.newPassword)" 42b1f559f0SSukanya Pandey @input="$v.form.newPassword.$touch()" 43b1f559f0SSukanya Pandey /> 44b1f559f0SSukanya Pandey <b-form-invalid-feedback role="alert"> 45b1f559f0SSukanya Pandey <template v-if="!$v.form.newPassword.required"> 46b1f559f0SSukanya Pandey {{ $t('global.form.fieldRequired') }} 47b1f559f0SSukanya Pandey </template> 48b1f559f0SSukanya Pandey <template 49b1f559f0SSukanya Pandey v-if=" 50b1f559f0SSukanya Pandey !$v.form.newPassword.minLength || 51b1f559f0SSukanya Pandey !$v.form.newPassword.maxLength 52b1f559f0SSukanya Pandey " 53b1f559f0SSukanya Pandey > 54b1f559f0SSukanya Pandey {{ 55b1f559f0SSukanya Pandey $t('profileSettings.newPassLabelTextInfo', { 56b1f559f0SSukanya Pandey min: passwordRequirements.minLength, 57b1f559f0SSukanya Pandey max: passwordRequirements.maxLength 58b1f559f0SSukanya Pandey }) 59b1f559f0SSukanya Pandey }} 60b1f559f0SSukanya Pandey </template> 61b1f559f0SSukanya Pandey </b-form-invalid-feedback> 62b1f559f0SSukanya Pandey </input-password-toggle> 63b1f559f0SSukanya Pandey </b-form-group> 64b1f559f0SSukanya Pandey <b-form-group 65b1f559f0SSukanya Pandey id="input-group-2" 66b1f559f0SSukanya Pandey :label="$t('profileSettings.confirmPassword')" 67b1f559f0SSukanya Pandey label-for="input-2" 68b1f559f0SSukanya Pandey > 69b1f559f0SSukanya Pandey <input-password-toggle> 70b1f559f0SSukanya Pandey <b-form-input 71b1f559f0SSukanya Pandey id="password-confirmation" 72b1f559f0SSukanya Pandey v-model="form.confirmPassword" 73b1f559f0SSukanya Pandey type="password" 74b1f559f0SSukanya Pandey :state="getValidationState($v.form.confirmPassword)" 75b1f559f0SSukanya Pandey @input="$v.form.confirmPassword.$touch()" 76b1f559f0SSukanya Pandey /> 77b1f559f0SSukanya Pandey <b-form-invalid-feedback role="alert"> 78b1f559f0SSukanya Pandey <template v-if="!$v.form.confirmPassword.required"> 79b1f559f0SSukanya Pandey {{ $t('global.form.fieldRequired') }} 80b1f559f0SSukanya Pandey </template> 81b1f559f0SSukanya Pandey <template v-else-if="!$v.form.confirmPassword.sameAsPassword"> 82b1f559f0SSukanya Pandey {{ $t('profileSettings.passwordsDoNotMatch') }} 83b1f559f0SSukanya Pandey </template> 84b1f559f0SSukanya Pandey </b-form-invalid-feedback> 85b1f559f0SSukanya Pandey </input-password-toggle> 86b1f559f0SSukanya Pandey </b-form-group> 87b1f559f0SSukanya Pandey </page-section> 88b1f559f0SSukanya Pandey </b-col> 89b1f559f0SSukanya Pandey </b-row> 90b1f559f0SSukanya Pandey <b-button variant="primary" type="submit"> 91b1f559f0SSukanya Pandey {{ $t('global.action.save') }} 92b1f559f0SSukanya Pandey </b-button> 93b1f559f0SSukanya Pandey </b-form> 94b1f559f0SSukanya Pandey </b-container> 95b1f559f0SSukanya Pandey</template> 96b1f559f0SSukanya Pandey 97b1f559f0SSukanya Pandey<script> 98b1f559f0SSukanya Pandeyimport BVToastMixin from '@/components/Mixins/BVToastMixin'; 99b1f559f0SSukanya Pandeyimport InputPasswordToggle from '@/components/Global/InputPasswordToggle'; 100b1f559f0SSukanya Pandeyimport { 101b1f559f0SSukanya Pandey maxLength, 102b1f559f0SSukanya Pandey minLength, 103b1f559f0SSukanya Pandey required, 104b1f559f0SSukanya Pandey sameAs 105b1f559f0SSukanya Pandey} from 'vuelidate/lib/validators'; 106*b93608dbSSukanya Pandeyimport LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; 107*b93608dbSSukanya Pandeyimport PageTitle from '@/components/Global/PageTitle'; 108*b93608dbSSukanya Pandeyimport PageSection from '@/components/Global/PageSection'; 109*b93608dbSSukanya Pandeyimport VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; 110b1f559f0SSukanya Pandey 111b1f559f0SSukanya Pandeyexport default { 112b1f559f0SSukanya Pandey name: 'ProfileSettings', 113*b93608dbSSukanya Pandey components: { InputPasswordToggle, PageSection, PageTitle }, 114*b93608dbSSukanya Pandey mixins: [BVToastMixin, LoadingBarMixin, VuelidateMixin], 115b1f559f0SSukanya Pandey data() { 116b1f559f0SSukanya Pandey return { 117b1f559f0SSukanya Pandey form: { 118b1f559f0SSukanya Pandey newPassword: '', 119b1f559f0SSukanya Pandey confirmPassword: '' 120b1f559f0SSukanya Pandey } 121b1f559f0SSukanya Pandey }; 122b1f559f0SSukanya Pandey }, 123*b93608dbSSukanya Pandey computed: { 124*b93608dbSSukanya Pandey username() { 125*b93608dbSSukanya Pandey return this.$store.getters['global/username']; 126*b93608dbSSukanya Pandey }, 127*b93608dbSSukanya Pandey passwordRequirements() { 128*b93608dbSSukanya Pandey return this.$store.getters['localUsers/accountPasswordRequirements']; 129*b93608dbSSukanya Pandey } 130*b93608dbSSukanya Pandey }, 131*b93608dbSSukanya Pandey created() { 132*b93608dbSSukanya Pandey this.startLoader(); 133*b93608dbSSukanya Pandey this.$store 134*b93608dbSSukanya Pandey .dispatch('localUsers/getAccountSettings') 135*b93608dbSSukanya Pandey .finally(() => this.endLoader()); 136*b93608dbSSukanya Pandey }, 137b1f559f0SSukanya Pandey validations() { 138b1f559f0SSukanya Pandey return { 139b1f559f0SSukanya Pandey form: { 140b1f559f0SSukanya Pandey newPassword: { 141b1f559f0SSukanya Pandey required, 142b1f559f0SSukanya Pandey minLength: minLength(this.passwordRequirements.minLength), 143b1f559f0SSukanya Pandey maxLength: maxLength(this.passwordRequirements.maxLength) 144b1f559f0SSukanya Pandey }, 145b1f559f0SSukanya Pandey confirmPassword: { 146b1f559f0SSukanya Pandey required, 147b1f559f0SSukanya Pandey sameAsPassword: sameAs('newPassword') 148b1f559f0SSukanya Pandey } 149b1f559f0SSukanya Pandey } 150b1f559f0SSukanya Pandey }; 151b1f559f0SSukanya Pandey }, 152b1f559f0SSukanya Pandey methods: { 153b1f559f0SSukanya Pandey submitForm() { 154b1f559f0SSukanya Pandey this.$v.$touch(); 155b1f559f0SSukanya Pandey if (this.$v.$invalid) return; 156b1f559f0SSukanya Pandey let userData = { 157b1f559f0SSukanya Pandey originalUsername: this.username, 158b1f559f0SSukanya Pandey password: this.form.newPassword 159b1f559f0SSukanya Pandey }; 160b1f559f0SSukanya Pandey 161b1f559f0SSukanya Pandey this.$store 162b1f559f0SSukanya Pandey .dispatch('localUsers/updateUser', userData) 163b1f559f0SSukanya Pandey .then(message => this.successToast(message)) 164b1f559f0SSukanya Pandey .catch(({ message }) => this.errorToast(message)); 165b1f559f0SSukanya Pandey } 166b1f559f0SSukanya Pandey } 167b1f559f0SSukanya Pandey}; 168b1f559f0SSukanya Pandey</script> 169