Kobus преди 5 години
родител
ревизия
192184cda4
променени са 2 файла, в които са добавени 15 реда и са изтрити 11 реда
  1. 14
    11
      src/components/user/loginPage.vue
  2. 1
    0
      src/store/modules/user/authentication.js

+ 14
- 11
src/components/user/loginPage.vue Целия файл

8
             <h4>Login</h4>
8
             <h4>Login</h4>
9
             <br />
9
             <br />
10
           </div>
10
           </div>
11
-          <!--<alert :text="'Login successful'" :type="'SUCCESS'" />
12
-          <alert :text="'User does not exist, please register'" :type="'ERROR'" />
13
-          <alert :text="'Username is incorrect'" :type="'WARNING'" />
14
-          <alert :text="'Password is incorrect'" :type="'WARNING'" />
15
-          <alert :text="'Caps Lock is on'" :type="'INFO'" />-->
11
+          <div v-if="this.$store.state.authentication.status === 'error'">
12
+            <alert
13
+              :text="'User doesn\'t exist or Username and Password is incorrect'"
14
+              :type="'ERROR'"
15
+            />
16
+          </div>
16
           <div class="row">
17
           <div class="row">
17
             <div class="col-md-11" style="margin-bottom: 1em">
18
             <div class="col-md-11" style="margin-bottom: 1em">
18
               <div class="input-group mb-3">
19
               <div class="input-group mb-3">
80
         <div class="form">
81
         <div class="form">
81
           <h5>Trouble signing in?</h5>
82
           <h5>Trouble signing in?</h5>
82
           <div>
83
           <div>
83
-            <!--<alert :text="'Username & password request email sent'" :type="'SUCCESS'" />-->
84
+            <!-- <alert :text="'Username & password request email sent'" :type="'SUCCESS'" /> -->
84
             <div class="row">
85
             <div class="row">
85
               <div class="input-group-prepend">
86
               <div class="input-group-prepend">
86
                 <span class="input-group-text">
87
                 <span class="input-group-text">
102
 
103
 
103
 <script>
104
 <script>
104
 import { mapActions, mapState } from 'vuex';
105
 import { mapActions, mapState } from 'vuex';
105
-// import alert from '../shared/alert.vue';
106
+import alert from '../shared/alert.vue';
106
 
107
 
107
 export default {
108
 export default {
108
   name: 'Login',
109
   name: 'Login',
109
   components: {
110
   components: {
110
-    // alert,
111
+    alert,
111
   },
112
   },
112
   data() {
113
   data() {
113
     return {
114
     return {
127
   methods: {
128
   methods: {
128
     ...mapActions('authentication', ['login', 'init']),
129
     ...mapActions('authentication', ['login', 'init']),
129
     Login() {
130
     Login() {
130
-      this.login()
131
-        .then(() => {})
132
-        .catch(() => {});
131
+      this.login().then(() => {
132
+        if (this.$store.state.authentication.status === 'error') {
133
+          this.$router.push('/user/login');
134
+        }
135
+      });
133
     },
136
     },
134
     togglePassword() {
137
     togglePassword() {
135
       this.showPassword = true;
138
       this.showPassword = true;

+ 1
- 0
src/store/modules/user/authentication.js Целия файл

94
             commit('auth_error');
94
             commit('auth_error');
95
             log.clearValues();
95
             log.clearValues();
96
             reject(err);
96
             reject(err);
97
+            commit('auth_error', err.data);
97
           });
98
           });
98
       });
99
       });
99
     },
100
     },

Loading…
Отказ
Запис