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;
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")
- }
-}
--- /dev/null
+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")
+ }
+}
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";
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;
+++ /dev/null
-/*
- Defines our User object
-*/
-export interface User {
- // Name
- name: string;
-
- // Realname
- realname?: string;
-}