mirror of
https://github.com/movie-web/movie-web.git
synced 2025-09-13 18:13:24 +00:00
36 lines
659 B
TypeScript
36 lines
659 B
TypeScript
import { ofetch } from "ofetch";
|
|
|
|
export interface SessionResponse {
|
|
id: string;
|
|
userId: string;
|
|
createdAt: string;
|
|
accessedAt: string;
|
|
device: string;
|
|
userAgent: string;
|
|
}
|
|
export interface LoginResponse {
|
|
session: SessionResponse;
|
|
token: string;
|
|
}
|
|
|
|
export function getAuthHeaders(token: string): Record<string, string> {
|
|
return {
|
|
authorization: `Bearer ${token}`,
|
|
};
|
|
}
|
|
|
|
export async function accountLogin(
|
|
url: string,
|
|
id: string,
|
|
deviceName: string,
|
|
): Promise<LoginResponse> {
|
|
return ofetch<LoginResponse>("/auth/login", {
|
|
method: "POST",
|
|
body: {
|
|
id,
|
|
device: deviceName,
|
|
},
|
|
baseURL: url,
|
|
});
|
|
}
|