diff --git a/next-ui/src/colada/claim.ts b/next-ui/src/colada/claim.ts
new file mode 100644
index 00000000..3bdd2d97
--- /dev/null
+++ b/next-ui/src/colada/claim.ts
@@ -0,0 +1,38 @@
+import { defineMutation, defineQuery, useMutation, useQuery, useQueryCache } from '@pinia/colada'
+import { komgaClient } from '@/api/komga-client'
+
+export const QUERY_KEYS_CLAIM = {
+ root: ['claim'] as const,
+}
+
+export const useClaimStatus = defineQuery(() => {
+ return useQuery({
+ key: () => QUERY_KEYS_CLAIM.root,
+ query: () =>
+ komgaClient
+ .GET('/api/v1/claim')
+ // unwrap the openapi-fetch structure on success
+ .then((res) => res.data),
+ // forever
+ staleTime: 0,
+ gcTime: false,
+ })
+})
+
+export const useClaimServer = defineMutation(() => {
+ const queryCache = useQueryCache()
+ return useMutation({
+ mutation: ({ username, password }: { username: string; password: string }) =>
+ komgaClient.POST('/api/v1/claim', {
+ params: {
+ header: {
+ 'X-Komga-Email': username,
+ 'X-Komga-Password': password,
+ },
+ },
+ }),
+ onSuccess: () => {
+ queryCache.cancelQueries({ key: QUERY_KEYS_CLAIM.root })
+ },
+ })
+})
diff --git a/next-ui/src/colada/users.ts b/next-ui/src/colada/users.ts
index cbfa6ce9..a58f7a32 100644
--- a/next-ui/src/colada/users.ts
+++ b/next-ui/src/colada/users.ts
@@ -52,6 +52,36 @@ export const useCurrentUser = defineQuery(() => {
}
})
+export const useLogin = defineMutation(() => {
+ const queryCache = useQueryCache()
+ return useMutation({
+ mutation: ({
+ username,
+ password,
+ rememberMe,
+ }: {
+ username: string
+ password: string
+ rememberMe?: boolean
+ }) =>
+ komgaClient.GET('/api/v2/users/me', {
+ headers: {
+ authorization: 'Basic ' + btoa(username + ':' + password),
+ 'X-Requested-With': 'XMLHttpRequest',
+ },
+ params: {
+ query: {
+ 'remember-me': rememberMe,
+ },
+ },
+ }),
+ onSuccess: ({ data }) => {
+ queryCache.setQueryData(QUERY_KEYS_USERS.currentUser, data)
+ queryCache.cancelQueries({ key: QUERY_KEYS_USERS.currentUser })
+ },
+ })
+})
+
export const useLogout = defineMutation(() => {
const queryCache = useQueryCache()
return useMutation({
diff --git a/next-ui/src/pages/claim.vue b/next-ui/src/pages/claim.vue
new file mode 100644
index 00000000..ecd3e39f
--- /dev/null
+++ b/next-ui/src/pages/claim.vue
@@ -0,0 +1,192 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+meta:
+ layout: single
+ noAuth: true
+
diff --git a/next-ui/src/pages/login.vue b/next-ui/src/pages/login.vue
index 705baf2b..86a7e4ef 100644
--- a/next-ui/src/pages/login.vue
+++ b/next-ui/src/pages/login.vue
@@ -1,6 +1,6 @@
@@ -116,18 +116,19 @@
diff --git a/next-ui/src/pages/startup.vue b/next-ui/src/pages/startup.vue
index 8ed61bea..d761d7c7 100644
--- a/next-ui/src/pages/startup.vue
+++ b/next-ui/src/pages/startup.vue
@@ -10,19 +10,24 @@