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

@@ -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 };
});