diff --git a/server/routes/auth.js b/server/routes/auth.js index 9647885..8194f13 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -23,6 +23,9 @@ router.post('/auth/logout', (req, res) => { }); router.get('/auth/current_user', (req, res) => { + if (!req.user) + return res.status(404).json({errors: 'No current user!'}) + res.send(req.user); }); diff --git a/web/src/components/Hero.vue b/web/src/components/Hero.vue deleted file mode 100644 index c8af5d2..0000000 --- a/web/src/components/Hero.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -   Welcome {{ username }}, - - - - - - - - - - \ No newline at end of file diff --git a/web/src/store/index.ts b/web/src/store/index.ts index 4ba7fe6..ad13791 100644 --- a/web/src/store/index.ts +++ b/web/src/store/index.ts @@ -63,11 +63,6 @@ export default createStore({ url: '/auth/current_user' }) .then((resp: AxiosResponse) => { - if (resp.data === "") { - commit('auth_error') - return - } - commit("auth_success", resp.data); resolve(resp) }) @@ -81,7 +76,7 @@ export default createStore({ modules: {}, getters: { isLoggedIn: state => state.status, - user: state => state.user + user: state => state.user, }, plugins: [createPersistedState()] }) diff --git a/web/src/views/Login.vue b/web/src/views/Login.vue index a884a5b..c213212 100644 --- a/web/src/views/Login.vue +++ b/web/src/views/Login.vue @@ -63,7 +63,7 @@ export default class Login extends Vue { this.$store.dispatch('getCurrentUser') .then(() => this.$router.push('/dashboard')) .catch((err: any) => { - this.$router.push('/') + this.$router.push('/login') }) } @@ -73,7 +73,6 @@ export default class Login extends Vue { this.$store.dispatch('login', user) .then(() => this.$router.push('/dashboard')) .catch((err: any) => { - console.log(err) this.msg = err.response.data.errors.message || err.message || 'Something went wrong!' this.$router.push('/login') })