feat: associate device id with username when logging in
This commit is contained in:
@@ -5,6 +5,7 @@ import { streamSSE } from "hono/streaming";
|
||||
import { fetchEpisodes } from "~/controllers/episodes/getByAniListId";
|
||||
import { maybeScheduleNextAiringEpisode } from "~/libs/maybeScheduleNextAiringEpisode";
|
||||
import { readEnvVariable } from "~/libs/readEnvVariable";
|
||||
import { associateDeviceIdWithUsername } from "~/models/token";
|
||||
import { setWatchStatus } from "~/models/watchStatus";
|
||||
import type { Env } from "~/types/env";
|
||||
import { EpisodesResponseSchema } from "~/types/episode";
|
||||
@@ -60,9 +61,8 @@ const route = createRoute({
|
||||
const app = new OpenAPIHono<Env>();
|
||||
|
||||
app.openapi(route, async (c) => {
|
||||
// const deviceId = await c.req.header("X-Aniplay-Device-Id");
|
||||
// const aniListToken = await c.req.header("X-AniList-Token");
|
||||
const { deviceId, token: aniListToken } = await c.req.query();
|
||||
const deviceId = await c.req.header("X-Aniplay-Device-Id");
|
||||
const aniListToken = await c.req.header("X-AniList-Token");
|
||||
|
||||
if (!aniListToken) {
|
||||
return c.json(ErrorResponse, { status: 401 });
|
||||
@@ -74,6 +74,8 @@ app.openapi(route, async (c) => {
|
||||
return c.json(ErrorResponse, { status: 401 });
|
||||
}
|
||||
|
||||
await associateDeviceIdWithUsername(env(c, "workerd"), deviceId, username);
|
||||
|
||||
return streamSSE(
|
||||
c,
|
||||
async (stream) => {
|
||||
|
||||
Reference in New Issue
Block a user