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

Removed code that did not work in the login promise

master
Lene Scholtz 5 роки тому
джерело
коміт
988d82e924

+ 2
- 1
src/components/shared/navBar.vue Переглянути файл

@@ -119,7 +119,7 @@
119 119
               </div>
120 120
             </li>
121 121
 
122
-            <li v-if="isLoggedIn" class="nav-item dropdown">
122
+            <li class="nav-item dropdown">
123 123
               <a
124 124
                 class="nav-link dropdown-toggle"
125 125
                 href="#"
@@ -128,6 +128,7 @@
128 128
                 data-toggle="dropdown"
129 129
                 aria-haspopup="true"
130 130
                 aria-expanded="false"
131
+                v-if="isLoggedIn"
131 132
               >Admin</a>
132 133
               <div class="dropdown-menu" aria-labelledby="navbarDropdown">
133 134
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/status/list')">Status</a>

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

@@ -132,6 +132,8 @@ export default {
132 132
       this.login().then(() => {
133 133
         if (this.$store.state.authentication.status === 'error') {
134 134
           this.$router.push('/user/login');
135
+        } else {
136
+          this.$router.push('/about/us');
135 137
         }
136 138
       });
137 139
     },
@@ -145,7 +147,6 @@ export default {
145 147
     },
146 148
     SendMail() {},
147 149
     routerGoTo(goTo) {
148
-      console.log(goTo);
149 150
       this.$router.push(goTo);
150 151
     },
151 152
   },

+ 19
- 30
src/store/modules/user/authentication.js Переглянути файл

@@ -53,9 +53,7 @@ export default {
53 53
     authStatus: state => state.status,
54 54
   },
55 55
   actions: {
56
-    init({
57
-      commit,
58
-    }) {
56
+    init({ commit }) {
59 57
       if (!log.isLoggedIn() && log.tokenExpired) {
60 58
         log.clearValues();
61 59
       } else log.updateTokenExpiry();
@@ -66,37 +64,28 @@ export default {
66 64
         agency: log.getJSONObject('agency'),
67 65
       });
68 66
     },
69
-    login({
70
-      commit,
71
-      state,
72
-    }) {
73
-      return new Promise((reject) => {
74
-        commit('auth_request');
75
-        const user = {
67
+    login({ commit, state }) {
68
+      axios({
69
+        url: '/api/register/authenticate',
70
+        data: {
76 71
           username: state.username,
77 72
           password: state.password,
78
-        };
79
-        axios({
80
-          url: '/api/register/authenticate',
81
-          data: user,
82
-          method: 'POST',
73
+        },
74
+        method: 'POST',
75
+      })
76
+        .then((resp) => {
77
+          log.clearValues();
78
+          log.setValues(resp.data);
79
+
80
+          commit('auth_success', resp.data);
83 81
         })
84
-          .then((resp) => {
85
-            log.clearValues();
86
-            log.setValues(resp.data);
87
-            commit('auth_success', resp.data);
88
-          })
89
-          .catch((err) => {
90
-            commit('auth_error');
91
-            log.clearValues();
92
-            reject(err);
93
-            commit('auth_error', err.data);
94
-          });
95
-      });
82
+        .catch((err) => {
83
+          commit('auth_error');
84
+          log.clearValues();
85
+          commit('auth_error', err.data);
86
+        });
96 87
     },
97
-    logout({
98
-      commit,
99
-    }) {
88
+    logout({ commit }) {
100 89
       return new Promise(() => {
101 90
         commit('logout');
102 91
         log.clearValues();

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