From e637d573a29bd09ccc07064b0f3dfdeaeb44ca4a Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Sun, 27 Jul 2025 00:25:19 +0530 Subject: [PATCH] Fixes --- docker-compose.alt.yml | 1 + src/components/auth/LoginForm.tsx | 1 + src/components/layout/MainLayout.tsx | 8 +-- .../organizations/OrganizationsList.tsx | 34 +++---------- src/pages/api/auth/oauth2/register.ts | 50 ++++++++++--------- 5 files changed, 38 insertions(+), 56 deletions(-) diff --git a/docker-compose.alt.yml b/docker-compose.alt.yml index 9e6a76e..87b82eb 100644 --- a/docker-compose.alt.yml +++ b/docker-compose.alt.yml @@ -15,6 +15,7 @@ services: - DATABASE_URL=file:data/gitea-mirror.db - HOST=0.0.0.0 - PORT=4321 + - BETTER_AUTH_URL=http://localhost:4321 - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your-secret-key-change-this-in-production} healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=3", "--spider", "http://localhost:4321/api/health"] diff --git a/src/components/auth/LoginForm.tsx b/src/components/auth/LoginForm.tsx index efad826..f987f00 100644 --- a/src/components/auth/LoginForm.tsx +++ b/src/components/auth/LoginForm.tsx @@ -68,6 +68,7 @@ export function LoginForm() { domain: domain, providerId: providerId, callbackURL: '/', + scopes: ['openid', 'email', 'profile'], // TODO: This is not being respected by the SSO plugin. }); } catch (error) { showErrorToast(error, toast); diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index 9341a54..776cd81 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -48,10 +48,10 @@ function AppWithProviders({ page: initialPage }: AppProps) { useRepoSync({ userId: user?.id, - enabled: user?.syncEnabled, - interval: user?.syncInterval, - lastSync: user?.lastSync, - nextSync: user?.nextSync, + enabled: false, // TODO: Get from config + interval: 3600, // TODO: Get from config + lastSync: null, + nextSync: null, }); // Handle navigation from sidebar diff --git a/src/components/organizations/OrganizationsList.tsx b/src/components/organizations/OrganizationsList.tsx index 2c3fd7c..49ba534 100644 --- a/src/components/organizations/OrganizationsList.tsx +++ b/src/components/organizations/OrganizationsList.tsx @@ -215,7 +215,7 @@ export function OrganizationList({ handleUpdateDestination(org.id!, newDestination)} isUpdating={isLoading} /> @@ -260,7 +260,7 @@ export function OrganizationList({ handleUpdateDestination(org.id!, newDestination)} isUpdating={isLoading} /> @@ -276,8 +276,9 @@ export function OrganizationList({ - {/* Repository breakdown */} - {isLoading || (org.status === "mirroring" && org.publicRepositoryCount === undefined) ? ( + {/* Repository breakdown - TODO: Add these properties to Organization type */} + {/* Commented out until repository count breakdown is available + {isLoading || (org.status === "mirroring") ? (
@@ -285,32 +286,9 @@ export function OrganizationList({
) : (
- {org.publicRepositoryCount !== undefined && ( -
-
- - {org.publicRepositoryCount} public - -
- )} - {org.privateRepositoryCount !== undefined && org.privateRepositoryCount > 0 && ( -
-
- - {org.privateRepositoryCount} private - -
- )} - {org.forkRepositoryCount !== undefined && org.forkRepositoryCount > 0 && ( -
-
- - {org.forkRepositoryCount} {org.forkRepositoryCount === 1 ? "fork" : "forks"} - -
- )}
)} + */}
diff --git a/src/pages/api/auth/oauth2/register.ts b/src/pages/api/auth/oauth2/register.ts index 2468772..096373e 100644 --- a/src/pages/api/auth/oauth2/register.ts +++ b/src/pages/api/auth/oauth2/register.ts @@ -1,7 +1,7 @@ import type { APIContext } from "astro"; import { createSecureErrorResponse } from "@/lib/utils"; import { requireAuth } from "@/lib/utils/auth-helpers"; -import { authClient } from "@/lib/auth-client"; +import { auth } from "@/lib/auth"; // POST /api/auth/oauth2/register - Register a new OAuth2 application export async function POST(context: APIContext) { @@ -47,36 +47,38 @@ export async function POST(context: APIContext) { } try { - // Use Better Auth client to register OAuth2 application - const response = await authClient.oauth2.register({ - client_name, - redirect_uris, - token_endpoint_auth_method, - grant_types, - response_types, - client_uri, - logo_uri, - scope, - contacts, - tos_uri, - policy_uri, - jwks_uri, - jwks, - metadata, - software_id, - software_version, - software_statement, + // Use Better Auth server API to register OAuth2 application + const response = await auth.api.registerOAuthApplication({ + body: { + client_name, + redirect_uris, + token_endpoint_auth_method, + grant_types, + response_types, + client_uri, + logo_uri, + scope, + contacts, + tos_uri, + policy_uri, + jwks_uri, + jwks, + metadata, + software_id, + software_version, + software_statement, + }, }); // Check if response is an error - if ('error' in response && response.error) { + if (!response || typeof response !== 'object') { return new Response( JSON.stringify({ - error: response.error.code || "registration_error", - error_description: response.error.message || "Failed to register application" + error: "registration_error", + error_description: "Invalid response from server" }), { - status: 400, + status: 500, headers: { "Content-Type": "application/json" }, } );