Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
update oauth
Browse files
ui/src/app/api/auth/hf/callback/route.ts
CHANGED
|
@@ -86,25 +86,35 @@ export async function GET(request: NextRequest) {
|
|
| 86 |
const namespace = profile?.preferred_username || profile?.name || 'user';
|
| 87 |
|
| 88 |
const script = `
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
-
|
| 96 |
-
|
| 97 |
`;
|
| 98 |
|
| 99 |
return htmlResponse(script.trim());
|
| 100 |
} catch (error: any) {
|
| 101 |
const message = error?.message || 'OAuth flow failed';
|
| 102 |
const script = `
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
`;
|
| 109 |
|
| 110 |
return htmlResponse(script.trim());
|
|
|
|
| 86 |
const namespace = profile?.preferred_username || profile?.name || 'user';
|
| 87 |
|
| 88 |
const script = `
|
| 89 |
+
(function() {
|
| 90 |
+
const target = window.opener || window.parent || window;
|
| 91 |
+
if (target) {
|
| 92 |
+
target.postMessage({
|
| 93 |
+
type: 'HF_OAUTH_SUCCESS',
|
| 94 |
+
payload: {
|
| 95 |
+
token: ${JSON.stringify(accessToken)},
|
| 96 |
+
namespace: ${JSON.stringify(namespace)},
|
| 97 |
+
}
|
| 98 |
+
}, '${origin}');
|
| 99 |
}
|
| 100 |
+
window.close();
|
| 101 |
+
})();
|
| 102 |
`;
|
| 103 |
|
| 104 |
return htmlResponse(script.trim());
|
| 105 |
} catch (error: any) {
|
| 106 |
const message = error?.message || 'OAuth flow failed';
|
| 107 |
const script = `
|
| 108 |
+
(function() {
|
| 109 |
+
const target = window.opener || window.parent || window;
|
| 110 |
+
if (target) {
|
| 111 |
+
target.postMessage({
|
| 112 |
+
type: 'HF_OAUTH_ERROR',
|
| 113 |
+
payload: { message: ${JSON.stringify(message)} }
|
| 114 |
+
}, '${origin}');
|
| 115 |
+
}
|
| 116 |
+
window.close();
|
| 117 |
+
})();
|
| 118 |
`;
|
| 119 |
|
| 120 |
return htmlResponse(script.trim());
|
ui/src/app/api/auth/hf/login/route.ts
CHANGED
|
@@ -18,7 +18,7 @@ export async function GET(request: NextRequest) {
|
|
| 18 |
authorizeUrl.searchParams.set('response_type', 'code');
|
| 19 |
authorizeUrl.searchParams.set('client_id', clientId);
|
| 20 |
authorizeUrl.searchParams.set('redirect_uri', redirectUri);
|
| 21 |
-
authorizeUrl.searchParams.set('scope', 'openid profile read-repos');
|
| 22 |
authorizeUrl.searchParams.set('state', state);
|
| 23 |
|
| 24 |
const response = NextResponse.redirect(authorizeUrl.toString(), { status: 302 });
|
|
|
|
| 18 |
authorizeUrl.searchParams.set('response_type', 'code');
|
| 19 |
authorizeUrl.searchParams.set('client_id', clientId);
|
| 20 |
authorizeUrl.searchParams.set('redirect_uri', redirectUri);
|
| 21 |
+
authorizeUrl.searchParams.set('scope', 'openid profile read-repos write-repos manage-repos jobs');
|
| 22 |
authorizeUrl.searchParams.set('state', state);
|
| 23 |
|
| 24 |
const response = NextResponse.redirect(authorizeUrl.toString(), { status: 302 });
|
ui/src/app/dashboard/page.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export default function Dashboard() {
|
|
| 22 |
<div className="border border-gray-800 rounded-xl bg-gray-900 p-6 flex flex-col gap-4">
|
| 23 |
<div>
|
| 24 |
<h2 className="text-xl font-semibold text-gray-100">
|
| 25 |
-
{isAuthenticated ? `Welcome back, ${namespace || 'creator'}!` : 'Welcome to Ostris AI Toolkit
|
| 26 |
</h2>
|
| 27 |
<p className="text-sm text-gray-400 mt-2">
|
| 28 |
{isAuthenticated
|
|
|
|
| 22 |
<div className="border border-gray-800 rounded-xl bg-gray-900 p-6 flex flex-col gap-4">
|
| 23 |
<div>
|
| 24 |
<h2 className="text-xl font-semibold text-gray-100">
|
| 25 |
+
{isAuthenticated ? `Welcome back, ${namespace || 'creator'}!` : 'Welcome to Ostris AI Toolkit'}
|
| 26 |
</h2>
|
| 27 |
<p className="text-sm text-gray-400 mt-2">
|
| 28 |
{isAuthenticated
|