Browse Source

Exception for User exists

master
30117125 4 years ago
parent
commit
c130a9c45c

+ 8
- 2
src/components/user/registerIndividual.vue View File

6
           <alert :text="'Register Success! You\'ll be redirected shortly.'" :type="'SUCCESS'" />
6
           <alert :text="'Register Success! You\'ll be redirected shortly.'" :type="'SUCCESS'" />
7
         </div>
7
         </div>
8
       </div>
8
       </div>
9
+      <div v-if="boolUserExists" class="row">
10
+        <div class="col">
11
+          <alert :text="'This username is already in use'" :type="'ERROR'" />
12
+        </div>
13
+      </div>
9
       <div class="row">
14
       <div class="row">
10
         <div class="col-sm-12 col-md-6 ">
15
         <div class="col-sm-12 col-md-6 ">
11
           <input
16
           <input
146
       showPassword: false,
151
       showPassword: false,
147
       boolMessage: false,
152
       boolMessage: false,
148
       terms: false,
153
       terms: false,
149
-      indivUser: {}
154
+      indivUser: {},
155
+      boolUserExists: false
150
     };
156
     };
151
   },
157
   },
152
   computed: {
158
   computed: {
183
           }, 2500);
189
           }, 2500);
184
         })
190
         })
185
         .catch(err => {
191
         .catch(err => {
186
-          console.log(err);
192
+          this.boolUserExists = true;
187
         });
193
         });
188
     },
194
     },
189
     Close() {
195
     Close() {

+ 7
- 3
src/components/user/registerPage.vue View File

109
       this.isPasswordShown = "password";
109
       this.isPasswordShown = "password";
110
     },
110
     },
111
     SubmitData() {
111
     SubmitData() {
112
-      this.saveIndividual(this.registerIndividual);
113
-
114
-      this.$router.push("/user/login");
112
+      this.saveIndividual(this.registerIndividual)
113
+        .then(() => {
114
+          this.$router.push("/user/login");
115
+        })
116
+        .catch(ex => {
117
+          //console.log(ex);
118
+        });
115
     },
119
     },
116
     Close() {
120
     Close() {
117
       this.$router.push("/user/login");
121
       this.$router.push("/user/login");

+ 5
- 2
src/store/modules/user/register.js View File

146
     // },
146
     // },
147
 
147
 
148
     async saveIndividual({ commit }, item) {
148
     async saveIndividual({ commit }, item) {
149
+      
149
       await axios
150
       await axios
150
         .post("/api/register/register", item)
151
         .post("/api/register/register", item)
151
         .then(res => {
152
         .then(res => {
152
           commit("addIndividual", res.data);
153
           commit("addIndividual", res.data);
154
+          return promise.resolve()
153
         })
155
         })
154
-        .catch(() => {
155
-          console.error;
156
+        .catch((ex) => {
157
+          return promise.reject(ex)
158
+          //console.error;
156
         });
159
         });
157
     },
160
     },
158
     saveAgency({ commit }, item) {
161
     saveAgency({ commit }, item) {

Loading…
Cancel
Save