Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(rnd): Route to /login on authenticated requests (#8111)

Zamil Majdy612e7cfed569
diff --git a/autogpt_platform/frontend/src/components/ProfileDropdown.tsx b/autogpt_platform/frontend/src/components/ProfileDropdown.tsx
index 4da31b9ae7..98d4ad8c0f 100644
--- a/autogpt_platform/frontend/src/components/ProfileDropdown.tsx
+++ b/autogpt_platform/frontend/src/components/ProfileDropdown.tsx
@@ -42,7 +42,11 @@ const ProfileDropdown = () => {
Admin Dashboard
</DropdownMenuItem>
)}
- <DropdownMenuItem onClick={() => supabase?.auth.signOut()}>
+ <DropdownMenuItem
+ onClick={() =>
+ supabase?.auth.signOut().then(() => router.replace("/login"))
+ }
+ >
Log out
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/baseClient.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/baseClient.ts
index eb7c6a4037..b7d53703c5 100644
--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/baseClient.ts
+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/baseClient.ts
@@ -195,6 +195,15 @@ export default class BaseAutoGPTServerAPI {
response_data.detail,
response,
);
+
+ if (
+ response.status === 403 &&
+ response_data.detail === "Not authenticated" &&
+ window // Browser environment only: redirect to login page.
+ ) {
+ window.location.href = "/login";
+ }
+
throw new Error(`HTTP error ${response.status}! ${response_data.detail}`);
}
return response_data;