aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/.server/auth.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-01 21:13:11 +0900
committernsfisis <nsfisis@gmail.com>2024-08-01 21:13:11 +0900
commit94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4 (patch)
tree46872e86ed7e42962895e0bfe04064387487523f /frontend/app/.server/auth.ts
parent7190fa225d1a559bacfb244fb1295e8bec246906 (diff)
downloadphperkaigi-2025-albatross-94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4.tar.gz
phperkaigi-2025-albatross-94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4.tar.zst
phperkaigi-2025-albatross-94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4.zip
refactor(frontend): provide simpler API client
Diffstat (limited to 'frontend/app/.server/auth.ts')
-rw-r--r--frontend/app/.server/auth.ts13
1 files changed, 2 insertions, 11 deletions
diff --git a/frontend/app/.server/auth.ts b/frontend/app/.server/auth.ts
index b80166b..b7e1820 100644
--- a/frontend/app/.server/auth.ts
+++ b/frontend/app/.server/auth.ts
@@ -3,22 +3,13 @@ import { FormStrategy } from "remix-auth-form";
import { jwtDecode } from "jwt-decode";
import type { Session } from "@remix-run/server-runtime";
import { sessionStorage } from "./session";
-import { apiClient } from "./api/client";
+import { apiPostLogin } from "./api/client";
import { components } from "./api/schema";
export const authenticator = new Authenticator<string>(sessionStorage);
async function login(username: string, password: string): Promise<string> {
- const { data, error } = await apiClient.POST("/login", {
- body: {
- username,
- password,
- },
- });
- if (error) {
- throw new Error(error.message);
- }
- return data.token;
+ return (await apiPostLogin(username, password)).token;
}
authenticator.use(