Blame view
src/pages/Administrator/resetPassword.vue
7.15 KB
006544386
|
1 2 3 4 5 |
<template> <v-app id="login"> <v-container fluid fill-height> <v-layout> <v-flex xs12 sm8 md8 lg5 offset-sm2 offset-lg3 class="mt-5"> |
68d742034
|
6 |
<v-toolbar class="card-styles mt-5" dark> |
006544386
|
7 |
<v-spacer></v-spacer> |
7858a465f
|
8 |
<v-toolbar-title>Change Password</v-toolbar-title> |
006544386
|
9 10 11 12 13 |
<v-spacer></v-spacer> </v-toolbar> <v-card class="elevation-1 pa-3" id="form"> <v-card-text> <v-flex xs12 sm8 md8 lg8 offset-sm2> |
79583580d
|
14 |
<v-form class="mt-3" ref="form" v-model="valid" lazy-validation> |
7858a465f
|
15 |
<!-- <v-select |
79583580d
|
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
:rules="userRule" label="Select User" :items="getRoles" item-text="name" item-value="name" v-model="resetPassword.name" @change="getUsers(resetPassword.name)" ></v-select> <v-select :rules="userNameRule" label="Select User Name" :items="getUsersName" item-text="email" item-value="email" v-model="resetPassword.email" |
7014df603
|
31 |
></v-select>--> |
7858a465f
|
32 33 34 35 36 37 38 39 40 41 42 |
<v-text-field :append-icon="e1 ? 'visibility_off' : 'visibility'" :append-icon-cb="() => (e1 = !e1)" :type="e1 ? 'password' : 'text'" :rules="oldPasswordRule" v-model="resetPassword.oldPassword" :error-messages="errors.collect('resetPassword.oldPassword')" v-validate="'required'" data-vv-name="resetPassword.oldPassword" label="Old Password" ></v-text-field> |
006544386
|
43 |
<v-text-field |
7858a465f
|
44 45 46 |
:append-icon="e1 ? 'visibility_off' : 'visibility'" :append-icon-cb="() => (e1 = !e1)" :type="e1 ? 'password' : 'text'" |
79583580d
|
47 48 49 50 51 |
:rules="newPasswordRule" v-model="resetPassword.newPassword" :error-messages="errors.collect('resetPassword.newPassword')" v-validate="'required'" data-vv-name="resetPassword.newPassword" |
006544386
|
52 53 54 |
label="New Password" ></v-text-field> <v-text-field |
7858a465f
|
55 56 57 |
:append-icon="e1 ? 'visibility_off' : 'visibility'" :append-icon-cb="() => (e1 = !e1)" :type="e1 ? 'password' : 'text'" |
79583580d
|
58 59 60 |
v-model="resetPassword.confirmPassword" :rules="rePasswordRule" :error-messages="errors.collect('password2')" |
d2c0f0a3f
|
61 |
v-validate="{ required: false, is: resetPassword.newPassword }" |
79583580d
|
62 63 |
data-vv-name="password2" data-vv-as="password" |
7014df603
|
64 |
label="Re-enter New Password" |
006544386
|
65 66 67 68 69 70 71 |
></v-text-field> </v-form> </v-flex> </v-card-text> <v-card-actions> <v-flex text-xs-center> <v-btn |
7858a465f
|
72 |
style="background-color: #71d9ea; color: #0c0754;" |
006544386
|
73 |
dark |
7858a465f
|
74 |
flat |
006544386
|
75 76 77 |
large :loading="loading" @click="reset" |
7858a465f
|
78 |
>Change Password</v-btn> |
006544386
|
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
</v-flex> </v-card-actions> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" :color="color" >{{ text }}</v-snackbar> </v-card> </v-flex> </v-layout> </v-container> </v-app> </template> <script> import http from "@/Services/http.js"; export default { data() { return { snackbar: false, y: "top", x: "right", mode: "", timeout: 4000, text: "", |
79583580d
|
107 |
color: "", |
7858a465f
|
108 |
e1: true, |
79583580d
|
109 110 111 112 113 |
password2: "", resetPassword: {}, getUsersName: [], getRoles: [], valid: true, |
006544386
|
114 |
loading: false, |
006544386
|
115 |
text: "Password Changed", |
006544386
|
116 |
newPassword: "", |
7858a465f
|
117 |
oldPassword: "", |
7014df603
|
118 119 120 121 122 |
userRule: [(v) => !!v || "User is required"], userNameRule: [(v) => !!v || "User Name is required"], oldPasswordRule: [(v) => !!v || "Old Password is required"], newPasswordRule: [(v) => !!v || "New Password is required"], rePasswordRule: [(v) => !!v || "Re-Password is required"], |
006544386
|
123 124 |
}; }, |
79583580d
|
125 126 |
mounted() { this.token = this.$store.state.token; |
7014df603
|
127 |
if (this.$store.state.role != "PARENT") { |
bdcd68fbc
|
128 129 |
this.getRole(); } |
79583580d
|
130 |
}, |
006544386
|
131 132 |
methods: { reset() { |
d2c0f0a3f
|
133 134 |
if ( this.$refs.form.validate() && |
7858a465f
|
135 |
this.resetPassword.oldPassword === this.resetPassword.oldPassword |
d2c0f0a3f
|
136 |
) { |
79583580d
|
137 |
this.loading = true; |
7858a465f
|
138 |
this.resetPassword.newPassword = this.resetPassword.newPassword; |
79583580d
|
139 |
http() |
7858a465f
|
140 |
.put("/change-password", this.resetPassword, { |
7014df603
|
141 |
headers: { Authorization: "Bearer " + this.token }, |
79583580d
|
142 |
}) |
7014df603
|
143 |
.then((response) => { |
79583580d
|
144 145 146 147 148 149 |
this.loading = false; this.snackbar = true; this.text = "Successfully Restet password !!"; this.color = "green"; this.clear(); }) |
7014df603
|
150 |
.catch((error) => { |
79583580d
|
151 152 153 154 155 156 157 158 159 160 |
// console.log("err====>",err); this.snackbar = true; this.text = "User Not Found or Incorrect currentPassword"; this.color = "error"; this.loading = false; }); } }, getRole() { this.showLoader = true; |
006544386
|
161 |
http() |
79583580d
|
162 |
.get("/getRolesList", { |
7014df603
|
163 |
headers: { Authorization: "Bearer " + this.token }, |
006544386
|
164 |
}) |
7014df603
|
165 |
.then((response) => { |
79583580d
|
166 167 168 169 170 171 172 173 |
for (let i = 0; i < response.data.data.length; i++) { if ( response.data.data[i].name != "SUPERADMIN" && response.data.data[i].name != "ADMIN" ) { this.getRoles.push(response.data.data[i]); this.showLoader = false; } |
006544386
|
174 |
} |
006544386
|
175 |
}) |
7014df603
|
176 |
.catch((error) => { |
79583580d
|
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
this.showLoader = false; if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } }); }, clear() { this.$refs.form.reset(); }, getUsers(roles) { this.showLoader = true; http() .get("/getUserWithRole", { params: { |
7014df603
|
193 |
name: roles, |
79583580d
|
194 |
}, |
7014df603
|
195 |
headers: { Authorization: "Bearer " + this.token }, |
79583580d
|
196 |
}) |
7014df603
|
197 |
.then((response) => { |
79583580d
|
198 199 |
this.getUsersName = response.data.data; }) |
7014df603
|
200 |
.catch((error) => { |
79583580d
|
201 202 203 204 205 206 |
this.showLoader = false; if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
006544386
|
207 |
}); |
7014df603
|
208 209 |
}, }, |
006544386
|
210 211 212 |
}; </script> <style scoped> |
68d742034
|
213 214 215 |
.card-styles { background: #7f62f8 !important; border-color: #7f62f8 !important; |
006544386
|
216 217 |
} </style> |