0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

refactor(console): sign out user when insufficient permissions (#5171)

This commit is contained in:
Gao Sun 2023-12-27 13:41:31 +08:00 committed by GitHub
parent 5e60ed4362
commit dde80f492e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,16 @@ export const useStaticApi = ({
// Clone the response to avoid "Response body is already used".
const data = await response.clone().json<RequestErrorBody>();
// This is what will happen when the user still has the legacy refresh token without
// organization scope. We should sign them out and redirect to the sign in page.
// TODO: This is a temporary solution to prevent the user from getting stuck in Console,
// which can be removed after all legacy refresh tokens are expired, i.e. after Jan 10th,
// 2024.
if (response.status === 403 && data.message === 'Insufficient permissions.') {
await signOut(postSignOutRedirectUri.href);
return;
}
// Inform and redirect un-authorized users to sign in page.
if (data.code === 'auth.forbidden') {
await show({