mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-01-29 13:50:53 +03:00
Fixed Tests
This commit is contained in:
@@ -4,7 +4,34 @@ import type { APIRoute } from "astro";
|
||||
export const ALL: APIRoute = async (ctx) => {
|
||||
// If you want to use rate limiting, make sure to set the 'x-forwarded-for' header
|
||||
// to the request headers from the context
|
||||
// ctx.request.headers.set("x-forwarded-for", ctx.clientAddress);
|
||||
if (ctx.clientAddress) {
|
||||
ctx.request.headers.set("x-forwarded-for", ctx.clientAddress);
|
||||
}
|
||||
|
||||
return auth.handler(ctx.request);
|
||||
try {
|
||||
return await auth.handler(ctx.request);
|
||||
} catch (error) {
|
||||
console.error("Auth handler error:", error);
|
||||
|
||||
// Check if this is an SSO callback error
|
||||
const url = new URL(ctx.request.url);
|
||||
if (url.pathname.includes('/sso/callback')) {
|
||||
// Redirect to error page for SSO errors
|
||||
return Response.redirect(
|
||||
`${ctx.url.origin}/auth-error?error=sso_callback_failed&error_description=${encodeURIComponent(
|
||||
error instanceof Error ? error.message : "SSO authentication failed"
|
||||
)}`,
|
||||
302
|
||||
);
|
||||
}
|
||||
|
||||
// Return a proper error response for other errors
|
||||
return new Response(JSON.stringify({
|
||||
error: "Internal server error",
|
||||
message: error instanceof Error ? error.message : "Unknown error"
|
||||
}), {
|
||||
status: 500,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
}
|
||||
};
|
||||
47
src/pages/auth-error.astro
Normal file
47
src/pages/auth-error.astro
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
import Layout from '@/layouts/main.astro';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
const error = Astro.url.searchParams.get('error');
|
||||
const errorDescription = Astro.url.searchParams.get('error_description');
|
||||
---
|
||||
|
||||
<Layout title="Authentication Error">
|
||||
<div class="container mx-auto px-4 py-8">
|
||||
<div class="max-w-md mx-auto">
|
||||
<div class="bg-red-50 border border-red-200 rounded-lg p-6">
|
||||
<h1 class="text-xl font-semibold text-red-800 mb-2">Authentication Error</h1>
|
||||
|
||||
<p class="text-red-700 mb-4">
|
||||
{errorDescription || error || 'An error occurred during authentication. This might be due to a temporary issue with the SSO provider.'}
|
||||
</p>
|
||||
|
||||
<div class="space-y-2">
|
||||
<p class="text-sm text-red-600">
|
||||
If you're experiencing issues with SSO login, please try:
|
||||
</p>
|
||||
<ul class="list-disc list-inside text-sm text-red-600 space-y-1">
|
||||
<li>Clearing your browser cookies and cache</li>
|
||||
<li>Using a different browser</li>
|
||||
<li>Logging in with email/password instead</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => window.location.href = '/login'}
|
||||
>
|
||||
Back to Login
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => window.location.href = '/'}
|
||||
>
|
||||
Go Home
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
Reference in New Issue
Block a user