added logout and removed stamps that arent mine

This commit is contained in:
2025-12-10 01:42:22 +00:00
parent 9a0c054968
commit 2ac72d1fd0
4 changed files with 32 additions and 26 deletions

View File

@@ -10,17 +10,23 @@ const loggedIn = computed(() => !!auth.user.username);
function handleLogin() {
auth.logIn(username.value, password.value);
}
function handleLogout() {
auth.logOut();
}
</script>
<template>
<div v-if="loggedIn">
<h1>Logged in</h1>
<p>{{ auth.user.ID }}</p>
<p>{{ auth.user.username }}</p>
<button @click="handleLogout">Log Out</button>
</div>
<div v-else>
<h1>login</h1>
<textarea v-model="username"></textarea>
<textarea type="password" v-model="password"></textarea>
<h1>Login</h1>
<input type="text" v-model="username" placeholder="Username" />
<input type="password" v-model="password" placeholder="Password" />
<button @click="handleLogin">Log In</button>
</div>
</template>

View File

@@ -1,22 +1,10 @@
<template>
<div>
<RouterLink to="/cv">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
<h1>CV</h1>
</RouterLink>
<RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink>
<RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink>
<RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink>
<RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink>
<RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
<h1>ADMIN</h1>
</RouterLink>
</div>
</template>

View File

@@ -1,14 +1,9 @@
<template>
<div class="flex-row">
<div>
<img src="/img/stamps/12351B56-A370-465D-A951-739A480A05EC.gif" />
<!-- <img src="/img/stamps/12351B56-A370-465D-A951-739A480A05EC.gif" />
<img src="/img/stamps/71663263-8E08-4873-8EE1-96DC342C57EB.gif" />
<img src="/img/stamps/8a0014c1.gif" />
</div>
<div>
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
<img src="/img/stamps/8a0014c1.gif" /> -->
</div>
</div>
</template>

View File

@@ -6,7 +6,12 @@ export const useAuthStore = defineStore("auth", () => {
const user = ref({});
checkToken();
function logOut() {
async function logOut() {
try {
const res = await axios.post("/api/auth/logout");
} catch (err) {
console.error(err);
}
user.value = {};
}
@@ -22,6 +27,18 @@ export const useAuthStore = defineStore("auth", () => {
}
}
async function createUser(username, password) {
try {
const res = await axios.post("/api/user", {
username,
password,
});
user.value = res.data;
} catch (err) {
console.error(err);
}
}
async function refreshToken() {
try {
const res = await axios.post("/api/auth/refresh");
@@ -40,5 +57,5 @@ export const useAuthStore = defineStore("auth", () => {
}
}
return { user, checkToken, logIn, refreshToken, logOut };
return { user, checkToken, logIn, refreshToken, logOut, createUser };
});