summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorDerick Montague <derick.montague@ibm.com>2019-12-24 05:53:49 +0300
committerYoshie Muranaka <yoshiemuranaka@gmail.com>2020-01-29 01:18:05 +0300
commit676f2fcaac7b81bc3a77c2ecc047d508927814d5 (patch)
tree61268fd6178f6a86bc4d51e53217569ec628204e /src/store
parent126eaabea5edf8df4ed0dfb9c7af4ea246a5628a (diff)
downloadwebui-vue-676f2fcaac7b81bc3a77c2ecc047d508927814d5.tar.xz
Add login form validation
- Sending incorrect credentials returns a 401 and we don't want the page to redirect if we are trying to login. Wrapped the redirect in an if block. - Returning a promise used by the logout action, which is needed when not redirecting the page. Didn't add to the if block since other errors that use the router to redirect will need the Promise returned also, e.g. 403. Signed-off-by: Derick Montague <derick.montague@ibm.com> Change-Id: I6db706ef7c71ed13baed95dc4264e6ae11d13ad3
Diffstat (limited to 'src/store')
-rw-r--r--src/store/api.js6
-rw-r--r--src/store/modules/Authentication/AuthenticanStore.js5
2 files changed, 9 insertions, 2 deletions
diff --git a/src/store/api.js b/src/store/api.js
index 4918d804..0f8c9484 100644
--- a/src/store/api.js
+++ b/src/store/api.js
@@ -10,12 +10,16 @@ api.interceptors.response.use(undefined, error => {
// TODO: Provide user with a notification and way to keep system active
if (response.status == 401) {
- window.location = '/login';
+ if (response.config.url != '/login') {
+ window.location = '/login';
+ }
}
if (response.status == 403) {
router.push({ name: 'unauthorized' });
}
+
+ return Promise.reject(error);
});
export default {
diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js
index 88456e95..3a554b6b 100644
--- a/src/store/modules/Authentication/AuthenticanStore.js
+++ b/src/store/modules/Authentication/AuthenticanStore.js
@@ -13,7 +13,7 @@ const AuthenticationStore = {
},
mutations: {
authRequest(state) {
- state.status = 'loading';
+ state.status = 'processing';
},
authSuccess(state) {
state.status = 'authenticated';
@@ -22,6 +22,9 @@ const AuthenticationStore = {
authError(state) {
state.status = 'error';
},
+ authReset(state) {
+ state.status = '';
+ },
logout(state) {
state.status = '';
Cookies.remove('XSRF-TOKEN');