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 (#5072)
simplify the consent path
This commit is contained in:
parent
7310e4289f
commit
b204ba8f74
5 changed files with 10 additions and 9 deletions
packages
core/src
experience/src
integration-tests/src/client
|
@ -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));
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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')
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue