Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- client/src/_core/hooks/useAuth.ts +1 -1
- client/src/components/DashboardLayout.tsx +2 -11
- client/src/const.ts +1 -12
- client/src/main.tsx +1 -1
client/src/_core/hooks/useAuth.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function useAuth(options?: UseAuthOptions) {
|
|
| 67 |
if (typeof window === "undefined") return;
|
| 68 |
if (window.location.pathname === redirectPath) return;
|
| 69 |
|
| 70 |
-
|
| 71 |
}, [
|
| 72 |
redirectOnUnauthenticated,
|
| 73 |
redirectPath,
|
|
|
|
| 67 |
if (typeof window === "undefined") return;
|
| 68 |
if (window.location.pathname === redirectPath) return;
|
| 69 |
|
| 70 |
+
console.warn("[Auth] Redirect blocked in useAuth: user should be guest.");
|
| 71 |
}, [
|
| 72 |
redirectOnUnauthenticated,
|
| 73 |
redirectPath,
|
client/src/components/DashboardLayout.tsx
CHANGED
|
@@ -62,21 +62,12 @@ export default function DashboardLayout({
|
|
| 62 |
<div className="flex flex-col items-center gap-8 p-8 max-w-md w-full">
|
| 63 |
<div className="flex flex-col items-center gap-6">
|
| 64 |
<h1 className="text-2xl font-semibold tracking-tight text-center">
|
| 65 |
-
|
| 66 |
</h1>
|
| 67 |
<p className="text-sm text-muted-foreground text-center max-w-sm">
|
| 68 |
-
|
| 69 |
</p>
|
| 70 |
</div>
|
| 71 |
-
<Button
|
| 72 |
-
onClick={() => {
|
| 73 |
-
window.location.href = getLoginUrl();
|
| 74 |
-
}}
|
| 75 |
-
size="lg"
|
| 76 |
-
className="w-full shadow-lg hover:shadow-xl transition-all"
|
| 77 |
-
>
|
| 78 |
-
Sign in
|
| 79 |
-
</Button>
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
);
|
|
|
|
| 62 |
<div className="flex flex-col items-center gap-8 p-8 max-w-md w-full">
|
| 63 |
<div className="flex flex-col items-center gap-6">
|
| 64 |
<h1 className="text-2xl font-semibold tracking-tight text-center">
|
| 65 |
+
Loading Session...
|
| 66 |
</h1>
|
| 67 |
<p className="text-sm text-muted-foreground text-center max-w-sm">
|
| 68 |
+
Please wait while we initialize your guest session.
|
| 69 |
</p>
|
| 70 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
</div>
|
| 72 |
</div>
|
| 73 |
);
|
client/src/const.ts
CHANGED
|
@@ -2,16 +2,5 @@ export { COOKIE_NAME, ONE_YEAR_MS } from "@shared/const";
|
|
| 2 |
|
| 3 |
// Generate login URL at runtime so redirect URI reflects the current origin.
|
| 4 |
export const getLoginUrl = () => {
|
| 5 |
-
|
| 6 |
-
const appId = import.meta.env.VITE_APP_ID || "hacking-factory";
|
| 7 |
-
const redirectUri = `${window.location.origin}/api/oauth/callback`;
|
| 8 |
-
const state = btoa(redirectUri);
|
| 9 |
-
|
| 10 |
-
const url = new URL(`${oauthPortalUrl}/app-auth`);
|
| 11 |
-
url.searchParams.set("appId", appId);
|
| 12 |
-
url.searchParams.set("redirectUri", redirectUri);
|
| 13 |
-
url.searchParams.set("state", state);
|
| 14 |
-
url.searchParams.set("type", "signIn");
|
| 15 |
-
|
| 16 |
-
return url.toString();
|
| 17 |
};
|
|
|
|
| 2 |
|
| 3 |
// Generate login URL at runtime so redirect URI reflects the current origin.
|
| 4 |
export const getLoginUrl = () => {
|
| 5 |
+
return "/";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
};
|
client/src/main.tsx
CHANGED
|
@@ -18,7 +18,7 @@ const redirectToLoginIfUnauthorized = (error: unknown) => {
|
|
| 18 |
|
| 19 |
if (!isUnauthorized) return;
|
| 20 |
|
| 21 |
-
|
| 22 |
};
|
| 23 |
|
| 24 |
queryClient.getQueryCache().subscribe(event => {
|
|
|
|
| 18 |
|
| 19 |
if (!isUnauthorized) return;
|
| 20 |
|
| 21 |
+
console.warn("[Auth] Redirect blocked: user should be guest.");
|
| 22 |
};
|
| 23 |
|
| 24 |
queryClient.getQueryCache().subscribe(event => {
|