]> git.ipfire.org Git - pbs.git/commitdiff
frontend: Move user stuff into an own file
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Jul 2025 13:58:41 +0000 (13:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Jul 2025 13:58:41 +0000 (13:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
frontend/src/api/auth.ts
frontend/src/api/users.ts [new file with mode: 0644]
frontend/src/composables/auth.ts
frontend/src/stores/auth.ts
frontend/src/types/User.ts [deleted file]

index 0b59190d0c0bf5cdf9452a81f86a85f8d7450da0..a956a91a74ae01726c1cb172c244d209573328f8 100644 (file)
@@ -1,5 +1,6 @@
 import api from "@/api"
-import type { User } from "@/types/User"
+import type { User } from "@/api/users"
+import { fetchCurrentUser } from "@/api/users"
 
 interface AuthResponse {
        access_token: string;
@@ -50,15 +51,3 @@ export async function authenticateUser(username: string, password: string): Prom
                throw new Error("Invalid username or password")
        }
 }
-
-/*
-       Returns the currently logged in user
-*/
-export async function fetchCurrentUser(): Promise<User> {
-       try {
-               const response = await api.get("/v1/auth/whoami")
-               return response.data
-       } catch (error) {
-               throw new Error("Failed to load user")
-       }
-}
diff --git a/frontend/src/api/users.ts b/frontend/src/api/users.ts
new file mode 100644 (file)
index 0000000..bcfda7b
--- /dev/null
@@ -0,0 +1,21 @@
+import api from "@/api"
+
+export interface User {
+       // Name
+       name: string;
+
+       // Realname
+       realname?: string;
+}
+
+/*
+       Returns the currently logged in user
+*/
+export async function fetchCurrentUser(): Promise<User> {
+       try {
+               const response = await api.get("/v1/auth/whoami")
+               return response.data
+       } catch (error) {
+               throw new Error("Failed to load user")
+       }
+}
index 9021be7f8de2398cc37ea7ac3542fa862b53a991..f3d82cfa8ec8a45557cbbdad7881f8f4e1dbbbf3 100644 (file)
@@ -1,7 +1,7 @@
 import { computed } from "vue";
 
 // Import types
-import type { User } from "@/types/User";
+import type { User } from "@/api/users";
 
 // Authentication Store
 import { useAuthStore } from "@/stores/auth";
index af7a1fdc9fcfc888129a3b8525b8f159d41c1236..16ede5c49ece0c8dc36a03c5b74925a139356c78 100644 (file)
@@ -1,6 +1,6 @@
 import { defineStore } from 'pinia'
-import type { User } from "@/types/User"
-import { fetchCurrentUser } from "@/api/auth"
+import type { User } from "@/api/users"
+import { fetchCurrentUser } from "@/api/users"
 
 interface AuthState {
        user: User | null;
diff --git a/frontend/src/types/User.ts b/frontend/src/types/User.ts
deleted file mode 100644 (file)
index aafa4db..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-       Defines our User object
-*/
-export interface User {
-       // Name
-       name: string;
-
-       // Realname
-       realname?: string;
-}