login isValid()
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
<template>
|
||||
<q-page class="flex flex-center">
|
||||
<h3>Página inicial</h3>
|
||||
<div class="column">
|
||||
<div class="row">
|
||||
{{ listaStore.pb.authStore.isValid ? "Es válido" : "No es válido" }}
|
||||
</div>
|
||||
<div class="row">{{ listaStore.pb.authStore.token }}</div>
|
||||
<div class="row">{{ listaStore.pb.authStore.model.id }}</div>
|
||||
</div>
|
||||
<q-btn @click="logout()">Cerrar</q-btn>
|
||||
</q-page>
|
||||
</template>
|
||||
|
||||
@@ -8,4 +15,8 @@
|
||||
import { ref } from "vue";
|
||||
import { useListaStore } from "../stores/lista.js";
|
||||
const listaStore = useListaStore();
|
||||
const logout = () => {
|
||||
listaStore.pb.authStore.clear();
|
||||
console.log(listaStore.pb.authStore.isValid);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
>
|
||||
<div class="column">
|
||||
<div class="row">
|
||||
<h5 class="text-h5 text-white q-my-md">Company & Co</h5>
|
||||
<h5 class="text-h5 text-white q-my-md">{{ listaStore.isAuth }}</h5>
|
||||
</div>
|
||||
<div class="row">
|
||||
<q-card square bordered class="q-pa-lg shadow-1">
|
||||
@@ -35,6 +35,7 @@
|
||||
size="lg"
|
||||
class="full-width"
|
||||
label="Login"
|
||||
@click="listaStore.login(email, password)"
|
||||
/>
|
||||
</q-card-actions>
|
||||
<q-card-section class="text-center q-pa-none">
|
||||
@@ -48,6 +49,8 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { useListaStore } from "../stores/lista.js";
|
||||
const listaStore = useListaStore();
|
||||
const email = ref("");
|
||||
const password = ref("");
|
||||
</script>
|
||||
|
||||
@@ -5,17 +5,19 @@ import PocketBase from "pocketbase";
|
||||
export const useListaStore = defineStore("lista", () => {
|
||||
const pb = new PocketBase("https://pocketbase.clonbg.es");
|
||||
const authData = ref("");
|
||||
function login() {
|
||||
async function login(email, password) {
|
||||
authData.value = pb
|
||||
.collection("users")
|
||||
.authWithPassword("clonbg", "m4nu3lm4nu3l")
|
||||
.authWithPassword(email, password)
|
||||
.then((r) => {
|
||||
console.log("logueado");
|
||||
this.router.push("/");
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("error");
|
||||
});
|
||||
}
|
||||
|
||||
return { pb, authData, login };
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user