mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
fix(console): fix the invalid_target error block console consent issue (#4592)
fix(console): fix the invalid_target error block AC consent issue fix the invalid_target error block AC consent issue
This commit is contained in:
parent
85a7461adc
commit
91d2412300
3 changed files with 57 additions and 4 deletions
|
@ -32,7 +32,7 @@
|
||||||
"@logto/language-kit": "workspace:^1.0.0",
|
"@logto/language-kit": "workspace:^1.0.0",
|
||||||
"@logto/phrases": "workspace:^1.5.0",
|
"@logto/phrases": "workspace:^1.5.0",
|
||||||
"@logto/phrases-experience": "workspace:^1.3.1",
|
"@logto/phrases-experience": "workspace:^1.3.1",
|
||||||
"@logto/react": "^2.1.0",
|
"@logto/react": "^2.1.2",
|
||||||
"@logto/schemas": "workspace:^1.9.1",
|
"@logto/schemas": "workspace:^1.9.1",
|
||||||
"@logto/shared": "workspace:^2.0.1",
|
"@logto/shared": "workspace:^2.0.1",
|
||||||
"@mdx-js/react": "^1.6.22",
|
"@mdx-js/react": "^1.6.22",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { LogtoClientError, LogtoError, OidcError } from '@logto/react';
|
import { LogtoClientError, LogtoError, OidcError, LogtoRequestError } from '@logto/react';
|
||||||
import { conditional } from '@silverhand/essentials';
|
import { conditional } from '@silverhand/essentials';
|
||||||
import { ResponseError } from '@withtyped/client';
|
import { ResponseError } from '@withtyped/client';
|
||||||
import { type TFunction } from 'i18next';
|
import { type TFunction } from 'i18next';
|
||||||
|
@ -11,6 +11,23 @@ import AppError from '@/components/AppError';
|
||||||
import SessionExpired from '@/components/SessionExpired';
|
import SessionExpired from '@/components/SessionExpired';
|
||||||
import { isInCallback } from '@/utils/url';
|
import { isInCallback } from '@/utils/url';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the error is an OIDC invalid_grant error.
|
||||||
|
*
|
||||||
|
* OIDC request error is globally converted to the LogtoRequestError.
|
||||||
|
* @see {@link @logto/core/packages/core/src/middleware/koa-oidc-error-handler.ts}
|
||||||
|
* We need to check the error code to determine if it is an OIDC invalid_grant error.
|
||||||
|
*/
|
||||||
|
const isOidcInvalidGrantError = (error: Error) => {
|
||||||
|
if (!(error instanceof LogtoRequestError)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const oidcGrantErrors = ['oidc.invalid_grant', 'oidc.invalid_target'];
|
||||||
|
|
||||||
|
return oidcGrantErrors.includes(error.code);
|
||||||
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
t: TFunction<'translation', 'admin_console'>;
|
t: TFunction<'translation', 'admin_console'>;
|
||||||
|
@ -70,6 +87,7 @@ class ErrorBoundary extends Component<Props, State> {
|
||||||
if (
|
if (
|
||||||
error instanceof LogtoError ||
|
error instanceof LogtoError ||
|
||||||
error instanceof LogtoClientError ||
|
error instanceof LogtoClientError ||
|
||||||
|
isOidcInvalidGrantError(error) ||
|
||||||
(error instanceof HTTPError && error.response.status === 401) ||
|
(error instanceof HTTPError && error.response.status === 401) ||
|
||||||
(error instanceof ResponseError && error.status === 401)
|
(error instanceof ResponseError && error.status === 401)
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -2852,8 +2852,8 @@ importers:
|
||||||
specifier: workspace:^1.3.1
|
specifier: workspace:^1.3.1
|
||||||
version: link:../phrases-experience
|
version: link:../phrases-experience
|
||||||
'@logto/react':
|
'@logto/react':
|
||||||
specifier: ^2.1.0
|
specifier: ^2.1.2
|
||||||
version: 2.1.0(react@18.2.0)
|
version: 2.1.2(react@18.2.0)
|
||||||
'@logto/schemas':
|
'@logto/schemas':
|
||||||
specifier: workspace:^1.9.1
|
specifier: workspace:^1.9.1
|
||||||
version: link:../schemas
|
version: link:../schemas
|
||||||
|
@ -7289,6 +7289,14 @@ packages:
|
||||||
js-base64: 3.7.5
|
js-base64: 3.7.5
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@logto/browser@2.1.2:
|
||||||
|
resolution: {integrity: sha512-LADZHT7LTyiWDwWmBwh3qAtOg+IVEjfaFKBTB/RQBc5T9xYO4q4JcyW1XgpMlkc0uLqOtW3uOGztUVs0ugi6/g==}
|
||||||
|
dependencies:
|
||||||
|
'@logto/client': 2.2.3
|
||||||
|
'@silverhand/essentials': 2.8.4
|
||||||
|
js-base64: 3.7.5
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@logto/client@2.1.0:
|
/@logto/client@2.1.0:
|
||||||
resolution: {integrity: sha512-vw8xDW8k38/58Q1r592z/9JdsmUh4+LMmoVm/Nu7LbWKlT32eD3H9hZDkFK9XEHpriifhI0hP7asGWEmhrEUuQ==}
|
resolution: {integrity: sha512-vw8xDW8k38/58Q1r592z/9JdsmUh4+LMmoVm/Nu7LbWKlT32eD3H9hZDkFK9XEHpriifhI0hP7asGWEmhrEUuQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -7307,6 +7315,15 @@ packages:
|
||||||
jose: 4.14.4
|
jose: 4.14.4
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@logto/client@2.2.3:
|
||||||
|
resolution: {integrity: sha512-xq4LhQ6ItbukAHgsMDcgfspTpdpO5sSfSEugpOrGP/nLwzGTfBO78OSUfMdBQEDr5+3SRmONuSjUBBwssOLINA==}
|
||||||
|
dependencies:
|
||||||
|
'@logto/js': 2.1.3
|
||||||
|
'@silverhand/essentials': 2.8.4
|
||||||
|
camelcase-keys: 7.0.2
|
||||||
|
jose: 4.14.4
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@logto/cloud@0.2.5-444ed49(zod@3.20.2):
|
/@logto/cloud@0.2.5-444ed49(zod@3.20.2):
|
||||||
resolution: {integrity: sha512-UirssRQV8+UAG/d0amK3qSrZstYW8+VUtfRWcKN8Ka0oJbPaNQL+fW+8OCB39ikQqT39KLrClXbThu3akPUWhw==}
|
resolution: {integrity: sha512-UirssRQV8+UAG/d0amK3qSrZstYW8+VUtfRWcKN8Ka0oJbPaNQL+fW+8OCB39ikQqT39KLrClXbThu3akPUWhw==}
|
||||||
engines: {node: ^18.12.0}
|
engines: {node: ^18.12.0}
|
||||||
|
@ -7345,6 +7362,14 @@ packages:
|
||||||
jose: 4.14.2
|
jose: 4.14.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@logto/js@2.1.3:
|
||||||
|
resolution: {integrity: sha512-TOuoC5gHx/SfY5gcGSBfw63x5TpM6Lm/9J5y0Jy003Z1DZARUlpz0KbzyCVAIC/+6qIefkmNPHKl1rq9MB/hog==}
|
||||||
|
dependencies:
|
||||||
|
'@silverhand/essentials': 2.8.4
|
||||||
|
camelcase-keys: 7.0.2
|
||||||
|
jose: 4.14.4
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@logto/node@2.1.1:
|
/@logto/node@2.1.1:
|
||||||
resolution: {integrity: sha512-joSzzAqaRKeEquRenoFrIXXkNxkJci5zSkk4afywz1P8tTcTysnV4eXaBmwXNpmDfQdtHBwRdSACZPLgeF8JiQ==}
|
resolution: {integrity: sha512-joSzzAqaRKeEquRenoFrIXXkNxkJci5zSkk4afywz1P8tTcTysnV4eXaBmwXNpmDfQdtHBwRdSACZPLgeF8JiQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -7366,6 +7391,16 @@ packages:
|
||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@logto/react@2.1.2(react@18.2.0):
|
||||||
|
resolution: {integrity: sha512-4Fz5GG5N7y9ynYVutuLZgBornkVccaxG1vmAOxt233wfFPmNzESJ+TlYGe2FbngC7z9xfT6c7f9Q+1LZQmrzVg==}
|
||||||
|
peerDependencies:
|
||||||
|
react: '>=16.8.0 || ^18.0.0'
|
||||||
|
dependencies:
|
||||||
|
'@logto/browser': 2.1.2
|
||||||
|
'@silverhand/essentials': 2.8.4
|
||||||
|
react: 18.2.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@manypkg/find-root@1.1.0:
|
/@manypkg/find-root@1.1.0:
|
||||||
resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==}
|
resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
Loading…
Reference in a new issue