This commit is contained in:
Arunavo Ray
2025-07-27 00:25:19 +05:30
parent 5f45a9a03d
commit e637d573a2
5 changed files with 38 additions and 56 deletions

View File

@@ -15,6 +15,7 @@ services:
- DATABASE_URL=file:data/gitea-mirror.db - DATABASE_URL=file:data/gitea-mirror.db
- HOST=0.0.0.0 - HOST=0.0.0.0
- PORT=4321 - PORT=4321
- BETTER_AUTH_URL=http://localhost:4321
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your-secret-key-change-this-in-production} - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your-secret-key-change-this-in-production}
healthcheck: healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=3", "--spider", "http://localhost:4321/api/health"] test: ["CMD", "wget", "--no-verbose", "--tries=3", "--spider", "http://localhost:4321/api/health"]

View File

@@ -68,6 +68,7 @@ export function LoginForm() {
domain: domain, domain: domain,
providerId: providerId, providerId: providerId,
callbackURL: '/', callbackURL: '/',
scopes: ['openid', 'email', 'profile'], // TODO: This is not being respected by the SSO plugin.
}); });
} catch (error) { } catch (error) {
showErrorToast(error, toast); showErrorToast(error, toast);

View File

@@ -48,10 +48,10 @@ function AppWithProviders({ page: initialPage }: AppProps) {
useRepoSync({ useRepoSync({
userId: user?.id, userId: user?.id,
enabled: user?.syncEnabled, enabled: false, // TODO: Get from config
interval: user?.syncInterval, interval: 3600, // TODO: Get from config
lastSync: user?.lastSync, lastSync: null,
nextSync: user?.nextSync, nextSync: null,
}); });
// Handle navigation from sidebar // Handle navigation from sidebar

View File

@@ -215,7 +215,7 @@ export function OrganizationList({
<MirrorDestinationEditor <MirrorDestinationEditor
organizationId={org.id!} organizationId={org.id!}
organizationName={org.name!} organizationName={org.name!}
currentDestination={org.destinationOrg} currentDestination={org.destinationOrg ?? undefined}
onUpdate={(newDestination) => handleUpdateDestination(org.id!, newDestination)} onUpdate={(newDestination) => handleUpdateDestination(org.id!, newDestination)}
isUpdating={isLoading} isUpdating={isLoading}
/> />
@@ -260,7 +260,7 @@ export function OrganizationList({
<MirrorDestinationEditor <MirrorDestinationEditor
organizationId={org.id!} organizationId={org.id!}
organizationName={org.name!} organizationName={org.name!}
currentDestination={org.destinationOrg} currentDestination={org.destinationOrg ?? undefined}
onUpdate={(newDestination) => handleUpdateDestination(org.id!, newDestination)} onUpdate={(newDestination) => handleUpdateDestination(org.id!, newDestination)}
isUpdating={isLoading} isUpdating={isLoading}
/> />
@@ -276,8 +276,9 @@ export function OrganizationList({
</span> </span>
</div> </div>
{/* Repository breakdown */} {/* Repository breakdown - TODO: Add these properties to Organization type */}
{isLoading || (org.status === "mirroring" && org.publicRepositoryCount === undefined) ? ( {/* Commented out until repository count breakdown is available
{isLoading || (org.status === "mirroring") ? (
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<Skeleton className="h-4 w-20" /> <Skeleton className="h-4 w-20" />
<Skeleton className="h-4 w-20" /> <Skeleton className="h-4 w-20" />
@@ -285,32 +286,9 @@ export function OrganizationList({
</div> </div>
) : ( ) : (
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
{org.publicRepositoryCount !== undefined && (
<div className="flex items-center gap-1.5">
<div className="h-2.5 w-2.5 rounded-full bg-emerald-500" />
<span className="text-muted-foreground">
{org.publicRepositoryCount} public
</span>
</div>
)}
{org.privateRepositoryCount !== undefined && org.privateRepositoryCount > 0 && (
<div className="flex items-center gap-1.5">
<div className="h-2.5 w-2.5 rounded-full bg-orange-500" />
<span className="text-muted-foreground">
{org.privateRepositoryCount} private
</span>
</div>
)}
{org.forkRepositoryCount !== undefined && org.forkRepositoryCount > 0 && (
<div className="flex items-center gap-1.5">
<div className="h-2.5 w-2.5 rounded-full bg-blue-500" />
<span className="text-muted-foreground">
{org.forkRepositoryCount} {org.forkRepositoryCount === 1 ? "fork" : "forks"}
</span>
</div>
)}
</div> </div>
)} )}
*/}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,7 +1,7 @@
import type { APIContext } from "astro"; import type { APIContext } from "astro";
import { createSecureErrorResponse } from "@/lib/utils"; import { createSecureErrorResponse } from "@/lib/utils";
import { requireAuth } from "@/lib/utils/auth-helpers"; 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 // POST /api/auth/oauth2/register - Register a new OAuth2 application
export async function POST(context: APIContext) { export async function POST(context: APIContext) {
@@ -47,8 +47,9 @@ export async function POST(context: APIContext) {
} }
try { try {
// Use Better Auth client to register OAuth2 application // Use Better Auth server API to register OAuth2 application
const response = await authClient.oauth2.register({ const response = await auth.api.registerOAuthApplication({
body: {
client_name, client_name,
redirect_uris, redirect_uris,
token_endpoint_auth_method, token_endpoint_auth_method,
@@ -66,17 +67,18 @@ export async function POST(context: APIContext) {
software_id, software_id,
software_version, software_version,
software_statement, software_statement,
},
}); });
// Check if response is an error // Check if response is an error
if ('error' in response && response.error) { if (!response || typeof response !== 'object') {
return new Response( return new Response(
JSON.stringify({ JSON.stringify({
error: response.error.code || "registration_error", error: "registration_error",
error_description: response.error.message || "Failed to register application" error_description: "Invalid response from server"
}), }),
{ {
status: 400, status: 500,
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
} }
); );