0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-24 22:41:28 -05:00

refactor(core,experience): simplify the consent path ()

simplify the consent path
This commit is contained in:
simeng-li 2023-12-08 15:14:51 +08:00 committed by GitHub
parent 7310e4289f
commit b204ba8f74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 9 deletions
packages
core/src
experience/src
integration-tests/src/client

View file

@ -11,12 +11,13 @@ import { getTenantId } from '#src/utils/tenant.js';
// Need To Align With UI
export const sessionNotFoundPath = '/unknown-session';
export const guardedPath = [
'/sign-in',
'/consent',
'/register',
'/single-sign-on',
'/social/register',
'/reset-password',
'/forgot-password',
];
@ -28,6 +29,7 @@ export default function koaSpaSessionGuard<
return async (ctx, next) => {
const requestPath = ctx.request.path;
const isPreview = ctx.request.URL.searchParams.get('preview');
const isSessionRequiredPath =
requestPath === '/' || guardedPath.some((path) => requestPath.startsWith(path));

View file

@ -159,11 +159,11 @@ export default function initOidc(envSet: EnvSet, queries: Queries, libraries: Li
const isSignUp =
ctx.oidc.params?.[OIDCExtraParametersKey.InteractionMode] === InteractionMode.signUp;
return appendParameters(isSignUp ? routes.signUp : routes.signIn.credentials);
return appendParameters(isSignUp ? routes.signUp : routes.signIn);
}
case 'consent': {
return routes.signIn.consent;
return routes.consent;
}
default: {

View file

@ -1,12 +1,11 @@
const signIn = '/sign-in';
const signUp = '/register';
const consent = '/consent';
export const routes = Object.freeze({
signIn: {
credentials: signIn,
consent: `${signIn}/consent`,
},
signIn,
signUp,
consent,
} as const);
export const verificationTimeout = 10 * 60 * 1000; // 10 mins.

View file

@ -50,7 +50,7 @@ const App = () => {
<AppBoundary>
<AppInsightsBoundary cloudRole="ui">
<Routes>
<Route path="sign-in/consent" element={<Consent />} />
<Route path="consent" element={<Consent />} />
<Route element={<AppLayout />}>
<Route
path="unknown-session"

View file

@ -100,7 +100,7 @@ export default class MockClient {
// Note: Should redirect to logto consent page
assert(
authResponse.statusCode === 303 && authResponse.headers.location === '/sign-in/consent',
authResponse.statusCode === 303 && authResponse.headers.location === '/consent',
new Error('Invoke auth before consent failed')
);