aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/oauth/refresh
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-09 00:41:20 -0700
committerFuwn <[email protected]>2024-10-09 00:41:43 -0700
commit998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch)
tree50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/routes/api/oauth/refresh
parentfeat(graphql): add badgeCount field (diff)
downloaddue.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz
due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/routes/api/oauth/refresh')
-rw-r--r--src/routes/api/oauth/refresh/+server.ts40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/routes/api/oauth/refresh/+server.ts b/src/routes/api/oauth/refresh/+server.ts
index b2b36db2..66b4209c 100644
--- a/src/routes/api/oauth/refresh/+server.ts
+++ b/src/routes/api/oauth/refresh/+server.ts
@@ -3,28 +3,28 @@ import { env as env2 } from '$env/dynamic/public';
import { redirect } from '@sveltejs/kit';
export const GET = async ({ url, cookies }) => {
- const formData = new FormData();
+ const formData = new FormData();
- formData.append('grant_type', 'refresh_token');
- formData.append('client_id', env2.PUBLIC_ANILIST_CLIENT_ID as string);
- formData.append('client_secret', env.ANILIST_CLIENT_SECRET as string);
- formData.append('refresh_token', url.searchParams.get('token') || '');
+ formData.append('grant_type', 'refresh_token');
+ formData.append('client_id', env2.PUBLIC_ANILIST_CLIENT_ID as string);
+ formData.append('client_secret', env.ANILIST_CLIENT_SECRET as string);
+ formData.append('refresh_token', url.searchParams.get('token') || '');
- const newUser = await (
- await fetch('https://anilist.co/api/v2/oauth/token', {
- method: 'POST',
- body: formData
- })
- ).json();
+ const newUser = await (
+ await fetch('https://anilist.co/api/v2/oauth/token', {
+ method: 'POST',
+ body: formData
+ })
+ ).json();
- cookies.set('user', JSON.stringify(newUser), {
- path: '/',
- maxAge: 60 * 60 * 24 * 7,
- httpOnly: false,
- sameSite: 'lax',
- secure: false
- });
+ cookies.set('user', JSON.stringify(newUser), {
+ path: '/',
+ maxAge: 60 * 60 * 24 * 7,
+ httpOnly: false,
+ sameSite: 'lax',
+ secure: false
+ });
- if (url.searchParams.get('redirect')) throw redirect(303, '/');
- else return Response.json(newUser);
+ if (url.searchParams.get('redirect')) throw redirect(303, '/');
+ else return Response.json(newUser);
};