mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 10:21:55 +00:00
Fix login not updating header bar
This commit is contained in:
parent
5a7184efa8
commit
9a6e4b4306
|
@ -38,6 +38,7 @@
|
|||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import Login from '@/views/Login.vue';
|
||||
import { State, Mutation } from 'vuex-class';
|
||||
import userService from '../../shared/userService';
|
||||
import BootswatchThemeSelect from '../BootswatchThemeSelect.vue';
|
||||
|
||||
|
@ -45,13 +46,13 @@ import BootswatchThemeSelect from '../BootswatchThemeSelect.vue';
|
|||
components: { Login, BootswatchThemeSelect },
|
||||
})
|
||||
export default class NavBar extends Vue {
|
||||
get loggedIn(): boolean {
|
||||
console.log(userService.loggedIn());
|
||||
return userService.loggedIn();
|
||||
}
|
||||
@State loggedIn;
|
||||
|
||||
@Mutation setLoggedIn;
|
||||
|
||||
logout(): void {
|
||||
userService.logout();
|
||||
this.setLoggedIn(false);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,7 +3,7 @@ import userService from './userService';
|
|||
|
||||
export const api = axios.create({
|
||||
baseURL: userService.apiBase,
|
||||
timeout: 2000,
|
||||
timeout: 5000,
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@ import Vuex from 'vuex';
|
|||
|
||||
import ftbotModule from './modules/ftbot';
|
||||
import alertsModule from './modules/alerts';
|
||||
import userService from '../shared/userService';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
ping: '',
|
||||
loggedIn: userService.loggedIn(),
|
||||
},
|
||||
modules: {
|
||||
ftbot: ftbotModule,
|
||||
|
@ -20,6 +22,9 @@ export default new Vuex.Store({
|
|||
const now = Date.now();
|
||||
state.ping = `${ping.status} ${now.toString()}`;
|
||||
},
|
||||
setLoggedIn(state, loggedin: boolean) {
|
||||
state.loggedIn = loggedin;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
refreshOnce({ dispatch }) {
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import { Mutation } from 'vuex-class';
|
||||
import userService from '../shared/userService';
|
||||
import { setBaseUrl } from '../shared/apiService';
|
||||
|
||||
|
@ -70,6 +71,8 @@ import { AuthPayload } from '../store/types';
|
|||
|
||||
@Component({})
|
||||
export default class Login extends Vue {
|
||||
@Mutation setLoggedIn;
|
||||
|
||||
$refs!: {
|
||||
form: HTMLFormElement;
|
||||
};
|
||||
|
@ -116,6 +119,7 @@ export default class Login extends Vue {
|
|||
.login(this.auth)
|
||||
.then(() => {
|
||||
console.log('Login success.');
|
||||
this.setLoggedIn(true);
|
||||
this.$nextTick(() => {
|
||||
this.$bvModal.hide('modal-prevent-closing');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user