enzostvs HF staff commited on
Commit
0fec1c4
β€’
1 Parent(s): 99e890b

wip signin

Browse files
src/lib/stores/use-user.ts CHANGED
@@ -5,9 +5,13 @@ export const userStore = writable<any>(null);
5
 
6
 
7
  export const openWindowLogin = async () => {
8
- const response = await fetch(`/api/auth/login`);
9
- const { redirect } = await response.json();
10
- if (redirect) {
11
- window.open(redirect, "_blank");
12
- }
 
 
 
 
13
  };
 
5
 
6
 
7
  export const openWindowLogin = async () => {
8
+ return window.open(
9
+ "/api/auth/login",
10
+ "Login to LoRAs Studio",
11
+ "menubar=no,width=500,height=777,location=no,resizable=no,scrollbars=yes,status=no"
12
+ );
13
+ // const response = await fetch(`/api/auth/login`);
14
+ // const { redirect } = await response.json();
15
+ // if (redirect) {
16
+ // }
17
  };
src/routes/api/auth/login/+server.ts CHANGED
@@ -1,10 +1,19 @@
1
- import { json } from '@sveltejs/kit';
2
  /** @type {import('./$types').RequestHandler} */
3
 
4
  export async function GET() {
5
  const REDIRECT_URI = `https://${process.env.SPACE_HOST}/login/callback`
6
 
7
- return json({
8
- redirect: `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${REDIRECT_URI}&scope=openid%20profile&state=STATE&response_type=code`,
9
- })
 
 
 
 
 
 
 
 
 
10
  }
 
1
+ import { redirect } from '@sveltejs/kit'
2
  /** @type {import('./$types').RequestHandler} */
3
 
4
  export async function GET() {
5
  const REDIRECT_URI = `https://${process.env.SPACE_HOST}/login/callback`
6
 
7
+ throw redirect(302, `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${REDIRECT_URI}&scope=openid%20profile&state=STATE&response_type=code`)
8
+
9
+ // return {
10
+ // headers: {
11
+ // Location: `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${REDIRECT_URI}&scope=openid%20profile&state=STATE&response_type=code`,
12
+ // status: 302
13
+ // }
14
+ // }
15
+
16
+ // return json({
17
+ // redirect: `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${REDIRECT_URI}&scope=openid%20profile&state=STATE&response_type=code`,
18
+ // })
19
  }
src/routes/login/callback/+page.svelte ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <div>
2
+ <h1>Callback</h1>
3
+ <p>Callback page</p>
4
+ </div>