Commit 037ab8b0 authored by amandazk's avatar amandazk

Navbar muda quando logado (funcionando)

parent 45d55c2c
......@@ -56,7 +56,6 @@ export default {
...mapActions('auth', ['login']),
async submit() {
try {
console.log('oi')
await this.login(this.user)
// this.$router.push( { path: '/' })
} catch(error) {
......
......@@ -46,23 +46,12 @@
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<template v-if="loggedIn">
<a
href="/login"
class="btn btn-outline-dark my-2 my-sm-0"
role="button"
>Entrar</a
>
</template>
<template v-else>
<a
href="/login"
class="btn btn-outline-dark my-2 my-sm-0"
role="button"
>Sair</a
>
</template>
<button v-if="isLoggedIn" class="btn btn-outline-dark my-2 my-sm-0" v-on:click="logout">
Sair
</button>
<button v-else class="btn btn-outline-dark my-2 my-sm-0" v-on:click="login">
Entrar
</button>
</form>
</div>
</nav>
......@@ -71,6 +60,20 @@
<script>
export default {
name: "NavBar",
computed: {
isLoggedIn() {
return window.localStorage.getItem("psIfc");
},
},
methods: {
login() {
window.location.replace("http://127.0.0.1:8000/accounts/login/");
},
logout() {
window.localStorage.removeItem("username");
window.location.replace("http://127.0.0.1:8000/");
},
},
};
</script>
......
......@@ -31,6 +31,10 @@ export const auth = {
// this.$router.push('/login')
// }
logout() {
window.localStorage.removeItem("username");
window.location.replace("http://127.0.0.1:8000/")
}
},
mutations: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment