update error page

This commit is contained in:
mlsmaycon
2026-02-10 16:54:05 +01:00
parent b16d63643c
commit 08d3867f41
5 changed files with 30 additions and 13 deletions

View File

@@ -95,7 +95,7 @@ func (mw *Middleware) Protect(next http.Handler) http.Handler {
if errDesc == "" { if errDesc == "" {
errDesc = "An error occurred during authentication" errDesc = "An error occurred during authentication"
} }
web.ServeErrorPage(w, r, http.StatusForbidden, "Access Denied", errDesc, requestID, web.ErrorStatus{Proxy: true, Destination: true}) web.ServeAccessDeniedPage(w, r, http.StatusForbidden, "Access Denied", errDesc, requestID)
return return
} }

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,7 @@ import { PoweredByNetBird } from "@/components/PoweredByNetBird";
import { StatusCard } from "@/components/StatusCard"; import { StatusCard } from "@/components/StatusCard";
import type { ErrorData } from "@/data"; import type { ErrorData } from "@/data";
export function ErrorPage({ code, title, message, proxy = true, destination = true, requestId }: ErrorData) { export function ErrorPage({ code, title, message, proxy = true, destination = true, requestId, simple = false }: ErrorData) {
useEffect(() => { useEffect(() => {
document.title = `${title} - NetBird Service`; document.title = `${title} - NetBird Service`;
}, [title]); }, [title]);
@@ -27,12 +27,14 @@ export function ErrorPage({ code, title, message, proxy = true, destination = tr
{/* Description */} {/* Description */}
<Description className="mt-2 mb-8 max-w-md">{message}</Description> <Description className="mt-2 mb-8 max-w-md">{message}</Description>
{/* Status Cards */} {/* Status Cards - hidden in simple mode */}
<div className="hidden sm:flex items-start justify-center w-full mt-6 mb-16 z-10 relative"> {!simple && (
<StatusCard icon={UserIcon} label="You" line={false} /> <div className="hidden sm:flex items-start justify-center w-full mt-6 mb-16 z-10 relative">
<StatusCard icon={WaypointsIcon} label="Proxy" success={proxy} /> <StatusCard icon={UserIcon} label="You" line={false} />
<StatusCard icon={Globe} label="Destination" success={destination} /> <StatusCard icon={WaypointsIcon} label="Proxy" success={proxy} />
</div> <StatusCard icon={Globe} label="Destination" success={destination} />
</div>
)}
{/* Buttons */} {/* Buttons */}
<div className="flex gap-3 justify-center items-center mb-6 z-10 relative"> <div className="flex gap-3 justify-center items-center mb-6 z-10 relative">

View File

@@ -12,6 +12,7 @@ export interface ErrorData {
proxy?: boolean proxy?: boolean
destination?: boolean destination?: boolean
requestId?: string requestId?: string
simple?: boolean
} }
// Data injected by Go templates // Data injected by Go templates

View File

@@ -160,3 +160,17 @@ func ServeErrorPage(w http.ResponseWriter, r *http.Request, code int, title, mes
}, },
}, code) }, code)
} }
// ServeAccessDeniedPage renders a simple access denied page without the connection status graph.
func ServeAccessDeniedPage(w http.ResponseWriter, r *http.Request, code int, title, message, requestID string) {
ServeHTTP(w, r, map[string]any{
"page": "error",
"error": map[string]any{
"code": code,
"title": title,
"message": message,
"requestId": requestID,
"simple": true,
},
}, code)
}