enzostvs HF staff commited on
Commit
9fceaf0
·
1 Parent(s): 7bb6a57

wip signin

Browse files
src/lib/stores/use-user.ts CHANGED
@@ -13,7 +13,10 @@ export const openWindowLogin = async () => {
13
  };
14
 
15
  export const loginFromCode = async (code: string) => {
16
- const request = await fetch(`/api/auth?code=${code}`);
 
 
 
17
  const { ok, token } = await request.json();
18
  if (ok) {
19
  cookies.set("hf_access_token", token, { expires: 1 });
 
13
  };
14
 
15
  export const loginFromCode = async (code: string) => {
16
+ const request = await fetch(`/api/auth`, {
17
+ method: "POST",
18
+ body: JSON.stringify({ code }),
19
+ });
20
  const { ok, token } = await request.json();
21
  if (ok) {
22
  cookies.set("hf_access_token", token, { expires: 1 });
src/routes/api/auth/+server.ts CHANGED
@@ -2,8 +2,8 @@
2
 
3
  import { json } from '@sveltejs/kit';
4
 
5
- export async function POST(request) {
6
- const code = request.url.searchParams.get('code')
7
 
8
  if (!code) {
9
  return json({
 
2
 
3
  import { json } from '@sveltejs/kit';
4
 
5
+ export async function POST({ request }) {
6
+ const { code } = await request.json()
7
 
8
  if (!code) {
9
  return json({