Browse Source

Exception for User exists

master
30117125 4 years ago
parent
commit
c130a9c45c

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

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

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

@@ -109,9 +109,13 @@ export default {
109 109
       this.isPasswordShown = "password";
110 110
     },
111 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 120
     Close() {
117 121
       this.$router.push("/user/login");

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

@@ -146,13 +146,16 @@ export default {
146 146
     // },
147 147
 
148 148
     async saveIndividual({ commit }, item) {
149
+      
149 150
       await axios
150 151
         .post("/api/register/register", item)
151 152
         .then(res => {
152 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 161
     saveAgency({ commit }, item) {

Loading…
Cancel
Save