diff --git a/src/pages/IndexPage.vue b/src/pages/IndexPage.vue
index aa59881..130a0a7 100644
--- a/src/pages/IndexPage.vue
+++ b/src/pages/IndexPage.vue
@@ -1,6 +1,13 @@
- Página inicial
+
+
+ {{ listaStore.pb.authStore.isValid ? "Es válido" : "No es válido" }}
+
+
{{ listaStore.pb.authStore.token }}
+
{{ listaStore.pb.authStore.model.id }}
+
+ Cerrar
@@ -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);
+};
diff --git a/src/pages/LoginPage.vue b/src/pages/LoginPage.vue
index 8e24f3f..e0f16e7 100644
--- a/src/pages/LoginPage.vue
+++ b/src/pages/LoginPage.vue
@@ -4,7 +4,7 @@
>
-
Company & Co
+ {{ listaStore.isAuth }}
@@ -35,6 +35,7 @@
size="lg"
class="full-width"
label="Login"
+ @click="listaStore.login(email, password)"
/>
@@ -48,6 +49,8 @@
diff --git a/src/stores/lista.js b/src/stores/lista.js
index a5209d1..245bc95 100644
--- a/src/stores/lista.js
+++ b/src/stores/lista.js
@@ -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 };
});