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

pull/8133/head^2
Zamil Majdy 2024-09-21 11:50:55 -05:00 committed by GitHub
parent 52ee846744
commit 612e7cfed5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -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>

View File

@ -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;