Spaces:
Runtime error
Runtime error
hf sign in
Browse files- app/api/login/route.ts +4 -1
- app/login/callback/page.tsx +7 -0
- components/main/index.tsx +4 -2
- prisma/schema.prisma +1 -1
app/api/login/route.ts
CHANGED
@@ -1,8 +1,11 @@
|
|
1 |
export async function GET(request: Request) {
|
2 |
console.log(process.env)
|
|
|
|
|
|
|
3 |
return Response.json(
|
4 |
{
|
5 |
-
redirect: `https://huggingface.co/oauth/authorize?redirect_uri=${
|
6 |
status: 200,
|
7 |
ok: true
|
8 |
}
|
|
|
1 |
export async function GET(request: Request) {
|
2 |
console.log(process.env)
|
3 |
+
|
4 |
+
const REDIRECT_URI = `https://${process.env.SPACE_HOST}/login/callback`
|
5 |
+
|
6 |
return Response.json(
|
7 |
{
|
8 |
+
redirect: `https://huggingface.co/oauth/authorize?redirect_uri=${REDIRECT_URI}&scope=openid%20profile&client_id=${process.env.OAUTH_CLIENT_ID}`,
|
9 |
status: 200,
|
10 |
ok: true
|
11 |
}
|
app/login/callback/page.tsx
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default function LoginCallback() {
|
2 |
+
return (
|
3 |
+
<div className="pb-32">
|
4 |
+
<p className="font-bold text-4xl text-white">LOGIN CALLBACK</p>
|
5 |
+
</div>
|
6 |
+
);
|
7 |
+
}
|
components/main/index.tsx
CHANGED
@@ -32,8 +32,10 @@ export const Main = () => {
|
|
32 |
|
33 |
const openLogin = async () => {
|
34 |
const response = await fetch(`/api/login`);
|
35 |
-
const
|
36 |
-
|
|
|
|
|
37 |
};
|
38 |
|
39 |
return (
|
|
|
32 |
|
33 |
const openLogin = async () => {
|
34 |
const response = await fetch(`/api/login`);
|
35 |
+
const { ok, redirect } = await response.json();
|
36 |
+
if (ok && redirect) {
|
37 |
+
window.open(redirect, "_blank");
|
38 |
+
}
|
39 |
};
|
40 |
|
41 |
return (
|
prisma/schema.prisma
CHANGED
@@ -4,7 +4,7 @@ generator client {
|
|
4 |
|
5 |
datasource db {
|
6 |
provider = "sqlite"
|
7 |
-
url = "file
|
8 |
}
|
9 |
|
10 |
model Collection {
|
|
|
4 |
|
5 |
datasource db {
|
6 |
provider = "sqlite"
|
7 |
+
url = "file:../data/dev.db"
|
8 |
}
|
9 |
|
10 |
model Collection {
|