Переглянути джерело

Change Password After Login

master
30117125 4 роки тому
джерело
коміт
906740919a

+ 93
- 0
src/components/user/firstLoginPasswordUpdate.vue Переглянути файл

@@ -0,0 +1,93 @@
1
+<template>
2
+  <main id="main" style="margin-top:-20px; padding-bottom: 500px">
3
+    <div class="container">
4
+      <div>
5
+        <div class="section-header">
6
+          <h2 style="padding-top:40px">New Password</h2>
7
+        </div>
8
+      </div>
9
+      <div class="row mb-4">
10
+        <div class="col-md-12">
11
+          <div v-if="boolSuccess">
12
+            <alert :text="'Password Updated! You will be redirected shortly.'" :type="'SUCCESS'" />
13
+          </div>
14
+          <div v-if="passMissMatch">
15
+            <alert :text="'The passwords do not match'" :type="'ERROR'" />
16
+          </div>
17
+        </div>
18
+      </div>
19
+      <div class="row mb-4">
20
+        <div class="col-md-6">
21
+          <float-label>
22
+            <input
23
+              name="password"
24
+              placeholder="PASSWORD"
25
+              class="form-control uniInput"
26
+              type="password"
27
+              v-model="password"
28
+              @input="passMissMatch = false"
29
+            />
30
+          </float-label>
31
+        </div>
32
+        <div class="col-md-6">
33
+          <float-label>
34
+            <input
35
+              name="confirmPassword"
36
+              placeholder="CONFIRM PASSWORD"
37
+              class="form-control uniInput"
38
+              type="password"
39
+              v-model="confirmPassword"
40
+              @input="passMissMatch = false"
41
+            />
42
+          </float-label>
43
+        </div>
44
+      </div>
45
+      <div class="row">
46
+        <div class="col">
47
+          <button class="btn-solid-blue" @click="updatePassword">Save</button>
48
+        </div>
49
+      </div>
50
+    </div>
51
+  </main>
52
+</template>
53
+
54
+<script>
55
+/* eslint-disable */
56
+import { mapActions } from "vuex";
57
+import Log from "../../assets/Log";
58
+import alert from "../shared/alert";
59
+
60
+export default {
61
+  components: {
62
+    alert
63
+  },
64
+  data() {
65
+    return {
66
+      password: "",
67
+      confirmPassword: "",
68
+      boolSuccess: false,
69
+      passMissMatch: false
70
+    };
71
+  },
72
+  methods: {
73
+    ...mapActions("register", ["updateIndividual"]),
74
+    updatePassword() {
75
+      if (this.password === this.confirmPassword) {
76
+        var userObj = Log.getUser();
77
+        userObj.password = this.password;
78
+        console.log(userObj);
79
+        this.updateIndividual(userObj).then(() => {
80
+          this.boolSuccess = true;
81
+          setTimeout(() => {
82
+            this.$router.push("/user/login");
83
+          }, 2000);
84
+        });
85
+      } else {
86
+        this.passMissMatch = true;
87
+      }
88
+    }
89
+  }
90
+};
91
+</script>
92
+
93
+<style lang="scss" scoped></style>

+ 6
- 1
src/components/user/loginPage.vue Переглянути файл

@@ -119,7 +119,12 @@ export default {
119 119
     Login() {
120 120
       this.login({ username: this.username, password: this.password })
121 121
         .then(() => {
122
-          this.$router.push("/");
122
+          console.log(Log.getUser());
123
+          if (!Log.getUser().loginPasswordChange) {
124
+            this.$router.push("/");
125
+          } else {
126
+            this.$router.push("/user/changePasswordOnLogin");
127
+          }
123 128
         })
124 129
         .catch(err => {
125 130
           this.error = true;

+ 6
- 0
src/router/index.js Переглянути файл

@@ -49,6 +49,7 @@ import changeLogPage from "../components/admin/status/changeLogPage.vue";
49 49
 import UnitConfiguration from "../components/admin/unitConfiguration/unitConfigurationPage.vue";
50 50
 import agentManagementPage from "../components/admin/status/agentsUserManagementPage.vue";
51 51
 import Fees from "../components/admin/fees/feesPage.vue";
52
+import PasswordOnLogin from "../components/user/firstLoginPasswordUpdate.vue";
52 53
 
53 54
 import ResortPage from "../components/timeshare/resort/resortPageNew.vue";
54 55
 import UnitPage from "../components/timeshare/resort/unit/unitPageNew.vue";
@@ -157,6 +158,11 @@ export default new Router({
157 158
       name: "UpdateInfo",
158 159
       component: UpdateInfo
159 160
     },
161
+    {
162
+      path: "/user/changePasswordOnLogin",
163
+      name: "PasswordOnLogin",
164
+      component: PasswordOnLogin
165
+    },
160 166
     {
161 167
       path: "/user/register",
162 168
       name: "PrivateIndividual",

+ 6
- 8
src/store/modules/user/register.js Переглянути файл

@@ -140,14 +140,12 @@ export default {
140 140
         .then(result => commit("addAgent", result.data))
141 141
         .catch(console.error);
142 142
     },
143
-    // updateIndividual({
144
-    //   commit,
145
-    // }, item) {
146
-    //   axios
147
-    //     .put('/api/individual', item)
148
-    //     .then(result => commit('updateIndividual', item))
149
-    //     .catch(console.error);
150
-    // },
143
+    async updateIndividual({ commit }, userParam) {
144
+      await axios
145
+        .put("/api/user", userParam)
146
+        .then(result => console.log(result))
147
+        .catch(console.error);
148
+    },
151 149
     // updateAgency({
152 150
     //   commit,
153 151
     // }, item) {

Завантаження…
Відмінити
Зберегти