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:
parent
5e60ed4362
commit
dde80f492e
1 changed files with 10 additions and 0 deletions
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue