Merge remote-tracking branch 'origin' into dev

This commit is contained in:
Marco Realacci 2022-12-22 16:30:20 +01:00
commit ec0b06affc
4 changed files with 26 additions and 13 deletions

View file

@ -1,23 +1,23 @@
{
"hash": "80447977",
"browserHash": "b98131b5",
"hash": "0c3e4771",
"browserHash": "01248067",
"optimized": {
"axios": {
"src": "../../axios/index.js",
"file": "axios.js",
"fileHash": "6b5eae63",
"fileHash": "d8d02cf0",
"needsInterop": true
},
"vue": {
"src": "../../vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "de50261f",
"fileHash": "f8034b26",
"needsInterop": false
},
"vue-router": {
"src": "../../vue-router/dist/vue-router.mjs",
"file": "vue-router.js",
"fileHash": "4cad12d6",
"fileHash": "b4ca170f",
"needsInterop": false
}
},

View file

@ -5,16 +5,26 @@ export default {
return {
modalTitle: "Modal Title",
modalMsg: "Modal Message",
logged_in: true,
}
},
methods: {
showModal(title, message) {
this.modalTitle = title;
this.modalMsg = message;
this.modalTitle = title
this.modalMsg = message
// Simulate a click on the hidden modal button to open it
this.$refs.openModal.click();
this.$refs.openModal.click()
},
setLoggedIn() {
this.logged_in = true
},
logout() {
localStorage.removeItem("token")
sessionStorage.removeItem("token")
this.logged_in = false
this.$router.push({ path: "/login" })
}
},
mounted() {
@ -30,6 +40,7 @@ export default {
// If the response is 401, redirect to /login
if (error.response.status === 401) {
this.$router.push({ path: '/login' })
this.logged_in = false;
return;
}
@ -53,13 +64,14 @@ export default {
<div class="container-fluid">
<div class="row">
<main class="mb-5">
<main>
<!-- The view is rendered here -->
<RouterView />
<div v-if="logged_in" class="mb-5 pb-3"></div> <!-- Empty div to avoid hiding items under the navbar. todo: find a better way to do this -->
</main>
<!-- Bottom navigation buttons -->
<nav id="global-nav" class="navbar fixed-bottom navbar-light bg-light row">
<nav v-if="logged_in" id="global-nav" class="navbar fixed-bottom navbar-light bg-light">
<div class="collapse navbar-collapse" id="navbarNav"></div>
<RouterLink to="/" class="col-4 text-center">
<i class="bi bi-house text-dark" style="font-size: 2em"></i>

View file

@ -23,9 +23,7 @@ export default {
},
methods: {
logout() {
localStorage.removeItem("token");
sessionStorage.removeItem("token");
this.$router.push({ path: "/login" });
this.$root.logout()
},
visit() {
this.$router.push({ path: "/profile/" + this.user_id });

View file

@ -29,6 +29,8 @@ export default {
sessionStorage.setItem("token", response.data["user_id"]);
localStorage.removeItem("token");
}
// Tell the root view to enable the navbar
this.$root.setLoggedIn();
// Update the header
this.$axiosUpdate();
@ -86,6 +88,7 @@ export default {
<button style="width: 100%" type="button" class="btn btn-primary btn-block mb-4" @click="login">Sign in</button>
<ErrorMsg v-if="errormsg" :msg="errormsg"></ErrorMsg>
<LoadingSpinner :loading="loading" />
<i class="text-center text-secondary d-flex flex-column">repeat after me: "best password is no password"</i>
</form>
</div>
</div>