-
+
@@ -59,10 +59,6 @@ globalStore.fetchRelease();
const route = useRoute();
-const hasOwnLogo = computed(
- () => route.path === '/login' || route.path === '/setup'
-);
-
const loggedIn = computed(
() => route.path !== '/login' && route.path !== '/setup'
);
diff --git a/src/app/stores/auth.ts b/src/app/stores/auth.ts
index fd5fbd9d..e1ed8d93 100644
--- a/src/app/stores/auth.ts
+++ b/src/app/stores/auth.ts
@@ -1,16 +1,16 @@
export const useAuthStore = defineStore('Auth', () => {
- const userData = ref();
+ const { data: userData, refresh: update } = useFetch('/api/session', {
+ method: 'get',
+ });
/**
* @throws if unsuccessful
*/
async function login(username: string, password: string, remember: boolean) {
- await api.createSession({ username, password, remember });
+ await $fetch('/api/session', {
+ method: 'post',
+ body: { username, password, remember },
+ });
return true as const;
}
@@ -18,15 +18,11 @@ export const useAuthStore = defineStore('Auth', () => {
* @throws if unsuccessful
*/
async function logout() {
- const response = await api.deleteSession();
+ const response = await $fetch('/api/session', {
+ method: 'delete',
+ });
return response.success;
}
- async function update() {
- // store role etc
- const { data: response } = await api.getSession();
- userData.value = response.value;
- }
-
return { userData, login, logout, update };
});
diff --git a/src/app/utils/api.ts b/src/app/utils/api.ts
index d901425e..231d533a 100644
--- a/src/app/utils/api.ts
+++ b/src/app/utils/api.ts
@@ -1,31 +1,4 @@
class API {
- async getSession() {
- return useFetch('/api/session', {
- method: 'get',
- });
- }
-
- async createSession({
- username,
- password,
- remember,
- }: {
- username: string;
- password: string | null;
- remember: boolean;
- }) {
- return $fetch('/api/session', {
- method: 'post',
- body: { username, password, remember },
- });
- }
-
- async deleteSession() {
- return $fetch('/api/session', {
- method: 'delete',
- });
- }
-
async getClients() {
return useFetch('/api/client', {
method: 'get',
diff --git a/src/server/api/session.post.ts b/src/server/api/session.post.ts
index 11a900ab..b4e7e9f8 100644
--- a/src/server/api/session.post.ts
+++ b/src/server/api/session.post.ts
@@ -40,5 +40,5 @@ export default defineEventHandler(async (event) => {
SERVER_DEBUG(`New Session: ${data.id}`);
- return { success: true, requiresPassword: true };
+ return { success: true };
});