From d2e56cf23396752a9879dc6bb7cdea135f2984bb Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Fri, 30 Apr 2021 18:43:30 +0200 Subject: [PATCH] Api refactoring fixes (#372) * Fix JS error when logging in with bad credentials * Remove duplicate error message if bad credentials Error is already nicely displayed in LoginForm --- frontend/src/api/users.js | 2 +- frontend/src/components/Login/LoginForm.vue | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/api/users.js b/frontend/src/api/users.js index edf85bc3a9e8..7d66798ee7ec 100644 --- a/frontend/src/api/users.js +++ b/frontend/src/api/users.js @@ -32,7 +32,7 @@ export const userAPI = { let response = await apiReq.post( authURLs.token, formData, - function() { return i18n.t('user.incorrect-username-or-password'); }, + null, function() { return i18n.t('user.user-successfully-logged-in'); } ); return response; diff --git a/frontend/src/components/Login/LoginForm.vue b/frontend/src/components/Login/LoginForm.vue index 52eca4c546a1..4e66c3ac21e5 100644 --- a/frontend/src/components/Login/LoginForm.vue +++ b/frontend/src/components/Login/LoginForm.vue @@ -98,11 +98,10 @@ export default { this.clear(); this.$store.commit("setToken", response.data.access_token); this.$emit("logged-in"); + let user = await api.users.self(); + this.$store.commit("setUserData", user); } - let user = await api.users.self(); - this.$store.commit("setUserData", user); - this.loading = false; }, },