Skip to content

Commit

Permalink
Fix broken logout link in desktop nav view (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetppro authored Nov 10, 2021
1 parent 2388a05 commit 46f13bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
19 changes: 17 additions & 2 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
</template>
<template slot="end">
<navigation v-if="isMobile" :isMobile="isMobile"
:activeItem="activeItem" :activeGroup="activeGroup" @toggleGroup="toggleGroup" />
:activeItem="activeItem" :activeGroup="activeGroup" @toggleGroup="toggleGroup"
@doLogout="doLogout" />
<b-navbar-item v-else tag="div">
<a href="#" @click.prevent="doLogout">{{ $t('users.logout') }}</a>
</b-navbar-item>
Expand Down Expand Up @@ -65,6 +66,7 @@
<script>
import Vue from 'vue';
import { mapState } from 'vuex';
import { uris } from './constants';
import Navigation from './components/Navigation.vue';
Expand All @@ -79,7 +81,6 @@ export default Vue.extend({
return {
activeItem: {},
activeGroup: {},
showLogout: Boolean,
windowWidth: window.innerWidth,
};
},
Expand Down Expand Up @@ -118,6 +119,20 @@ export default Vue.extend({
}, 500);
});
},
doLogout() {
const http = new XMLHttpRequest();
const u = uris.root.substr(-1) === '/' ? uris.root : `${uris.root}/`;
http.open('get', `${u}api/logout`, false, 'logout_non_user', 'logout_non_user');
http.onload = () => {
document.location.href = uris.root;
};
http.onerror = () => {
document.location.href = uris.root;
};
http.send();
},
},
computed: {
Expand Down
14 changes: 1 addition & 13 deletions frontend/src/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@


<script>
import { uris } from '../constants';
export default {
name: 'navigation',
Expand All @@ -99,17 +97,7 @@ export default {
},
doLogout() {
const http = new XMLHttpRequest();
const u = uris.root.substr(-1) === '/' ? uris.root : `${uris.root}/`;
http.open('get', `${u}api/logout`, false, 'logout_non_user', 'logout_non_user');
http.onload = () => {
document.location.href = uris.root;
};
http.onerror = () => {
document.location.href = uris.root;
};
http.send();
this.$emit('doLogout');
},
},
};
Expand Down

0 comments on commit 46f13bf

Please sign in to comment.