2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2022-03-17 11:55:51 +00:00
|
|
|
<div class="password-edit flex-divided-view">
|
|
|
|
<div class="form--wrap w-full">
|
|
|
|
<auth-header
|
|
|
|
:title="$t('SET_NEW_PASSWORD.TITLE')"
|
|
|
|
:sub-title="$t('SET_NEW_PASSWORD.DESCRIPTION')"
|
|
|
|
/>
|
|
|
|
<form class="" @submit.prevent="login()">
|
|
|
|
<div class="input-wrap">
|
|
|
|
<auth-input
|
|
|
|
v-model.trim="credentials.password"
|
|
|
|
type="password"
|
|
|
|
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
|
|
|
icon-name="lock-closed"
|
|
|
|
:class="{ error: $v.credentials.password.$error }"
|
|
|
|
:label="$t('LOGIN.PASSWORD.LABEL')"
|
|
|
|
:error="
|
|
|
|
$v.credentials.password.$error
|
|
|
|
? $t('SET_NEW_PASSWORD.PASSWORD.ERROR')
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
@input="$v.credentials.password.$touch"
|
|
|
|
@blur="$v.credentials.password.$touch"
|
|
|
|
/>
|
|
|
|
<auth-input
|
|
|
|
v-model.trim="credentials.confirmPassword"
|
|
|
|
type="password"
|
|
|
|
icon-name="lock-shield"
|
|
|
|
:class="{ error: $v.credentials.confirmPassword.$error }"
|
|
|
|
:label="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.LABEL')"
|
|
|
|
:placeholder="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.PLACEHOLDER')"
|
|
|
|
:error="
|
|
|
|
$v.credentials.confirmPassword.$error
|
|
|
|
? $t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.ERROR')
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
@blur="$v.credentials.confirmPassword.$touch"
|
|
|
|
@input="$v.credentials.confirmPassword.$touch"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<auth-submit-button
|
|
|
|
:label="$t('SET_NEW_PASSWORD.SUBMIT')"
|
|
|
|
:is-disabled="
|
|
|
|
$v.credentials.password.$invalid ||
|
|
|
|
$v.credentials.confirmPassword.$invalid ||
|
|
|
|
newPasswordAPI.showLoading
|
|
|
|
"
|
|
|
|
:is-loading="newPasswordAPI.showLoading"
|
|
|
|
icon="arrow-chevron-right"
|
|
|
|
@click="login()"
|
2020-02-16 11:50:38 +00:00
|
|
|
/>
|
2022-03-17 11:55:51 +00:00
|
|
|
<!-- <input type="submit" class="button " v-on:click.prevent="login()" v-bind:value="" > -->
|
|
|
|
</form>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2022-03-17 11:55:51 +00:00
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { required, minLength } from 'vuelidate/lib/validators';
|
|
|
|
import Auth from '../../api/auth';
|
2022-03-17 11:55:51 +00:00
|
|
|
import AuthInput from './components/AuthInput';
|
|
|
|
import AuthHeader from 'dashboard/routes/auth/components/AuthHeader';
|
|
|
|
import AuthSubmitButton from './components/AuthSubmitButton';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2021-05-28 13:51:16 +00:00
|
|
|
import { DEFAULT_REDIRECT_URL } from '../../constants';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2022-03-17 11:55:51 +00:00
|
|
|
AuthInput,
|
|
|
|
AuthHeader,
|
|
|
|
AuthSubmitButton,
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
props: {
|
2021-12-27 08:19:31 +00:00
|
|
|
resetPasswordToken: { type: String, default: '' },
|
|
|
|
redirectUrl: { type: String, default: '' },
|
|
|
|
config: { type: String, default: '' },
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// We need to initialize the component with any
|
|
|
|
// properties that will be used in it
|
|
|
|
credentials: {
|
|
|
|
confirmPassword: '',
|
|
|
|
password: '',
|
|
|
|
},
|
|
|
|
newPasswordAPI: {
|
|
|
|
message: '',
|
|
|
|
showLoading: false,
|
|
|
|
},
|
|
|
|
error: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
// If url opened without token
|
|
|
|
// redirect to login
|
|
|
|
if (!this.resetPasswordToken) {
|
2021-05-28 13:51:16 +00:00
|
|
|
window.location = DEFAULT_REDIRECT_URL;
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
validations: {
|
|
|
|
credentials: {
|
|
|
|
password: {
|
|
|
|
required,
|
|
|
|
minLength: minLength(6),
|
|
|
|
},
|
|
|
|
confirmPassword: {
|
|
|
|
required,
|
|
|
|
minLength: minLength(6),
|
|
|
|
isEqPassword(value) {
|
|
|
|
if (value !== this.credentials.password) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
showAlert(message) {
|
|
|
|
// Reset loading, current selected agent
|
|
|
|
this.newPasswordAPI.showLoading = false;
|
|
|
|
bus.$emit('newToastMessage', message);
|
|
|
|
},
|
|
|
|
login() {
|
|
|
|
this.newPasswordAPI.showLoading = true;
|
|
|
|
const credentials = {
|
|
|
|
confirmPassword: this.credentials.confirmPassword,
|
|
|
|
password: this.credentials.password,
|
|
|
|
resetPasswordToken: this.resetPasswordToken,
|
|
|
|
};
|
|
|
|
Auth.setNewPassword(credentials)
|
2020-02-16 11:50:38 +00:00
|
|
|
.then(res => {
|
2019-08-14 09:48:44 +00:00
|
|
|
if (res.status === 200) {
|
2021-05-28 13:51:16 +00:00
|
|
|
window.location = DEFAULT_REDIRECT_URL;
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
})
|
2021-06-07 11:56:08 +00:00
|
|
|
.catch(error => {
|
|
|
|
let errorMessage = this.$t('SET_NEW_PASSWORD.API.ERROR_MESSAGE');
|
|
|
|
if (error?.data?.message) {
|
|
|
|
errorMessage = error.data.message;
|
|
|
|
}
|
|
|
|
this.showAlert(errorMessage);
|
2019-08-14 09:48:44 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2022-03-17 11:55:51 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.password-edit {
|
|
|
|
flex-direction: column;
|
|
|
|
margin: var(--space-larger) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.input-wrap {
|
|
|
|
padding-bottom: var(--space-one);
|
|
|
|
}
|
|
|
|
</style>
|