added logout and removed stamps that arent mine
This commit is contained in:
@@ -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 };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user