mirror of
https://git.suyu.dev/suyu/website.git
synced 2026-01-05 14:08:08 +01:00
add account deletion
This commit is contained in:
parent
c5686166d7
commit
5351c54d8d
9 changed files with 110 additions and 37 deletions
|
|
@ -1,8 +1,16 @@
|
|||
import type { CreateAccountRequest, CreateAccountResponse } from "$types/api";
|
||||
import type { CreateAccountRequest, CreateAccountResponse, GetUserResponse } from "$types/api";
|
||||
|
||||
const apiUsers = {
|
||||
async createAccount(body: CreateAccountRequest): Promise<CreateAccountResponse> {
|
||||
return await SuyuAPI.req("POST", "/api/user/create-account", body);
|
||||
return await SuyuAPI.req("POST", "/api/user", body);
|
||||
},
|
||||
|
||||
async deleteAccount() {
|
||||
return await SuyuAPI.req("DELETE", "/api/user");
|
||||
},
|
||||
|
||||
async getUser(): Promise<GetUserResponse> {
|
||||
return await SuyuAPI.req("GET", "/api/user");
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { userRepo } from "$lib/server/repo";
|
||||
import type { SuyuUser } from "$lib/server/schema";
|
||||
import cookie from "cookie";
|
||||
|
||||
export async function useAuth(request: Request | string): Promise<SuyuUser | null> {
|
||||
const apiKey = typeof request === "string" ? request : request.headers.get("Authorization");
|
||||
const apiKey =
|
||||
typeof request === "string"
|
||||
? request
|
||||
: cookie.parse(request.headers.get("cookie") || "").token;
|
||||
if (!apiKey) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue