0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-31 22:51:25 -05:00

feat(experience): add redirect uri info (#5296)

add redirect uri info
This commit is contained in:
simeng-li 2024-01-25 11:48:01 +08:00 committed by GitHub
parent 09de2996d0
commit 52411f6712
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 49 additions and 3 deletions

View file

@ -26,7 +26,7 @@ import assertThat from '#src/utils/assert-that.js';
import { interactionPrefix } from './const.js';
import type { WithInteractionDetailsContext } from './middleware/koa-interaction-details.js';
const { InvalidClient, InvalidTarget } = errors;
const { InvalidClient, InvalidTarget, InvalidRedirectUri } = errors;
/**
* Parse the missing resource scopes info with details. We need to display the resource name and scope details on the consent page.
@ -182,7 +182,7 @@ export default function consentRoutes<T extends IRouterParamContext>(
const {
session,
params: { client_id: clientId },
params: { client_id: clientId, redirect_uri: redirectUri },
prompt,
} = interactionDetails;
@ -193,6 +193,11 @@ export default function consentRoutes<T extends IRouterParamContext>(
new InvalidClient('client must be available')
);
assertThat(
redirectUri && typeof redirectUri === 'string',
new InvalidRedirectUri('redirect_uri must be available')
);
const { accountId } = session;
const application = await queries.applications.findApplicationById(clientId);
@ -230,6 +235,7 @@ export default function consentRoutes<T extends IRouterParamContext>(
),
// Parse the missing resource scopes info with details.
missingResourceScopes: await parseMissingResourceScopesInfo(queries, missingResourceScopes),
redirectUri,
} satisfies ConsentInfoResponse;
return next();

View file

@ -6,6 +6,13 @@
margin-top: _.unit(6);
}
.redirectUri {
margin-top: _.unit(5);
text-align: center;
font: var(--font-label-3);
color: var(--color-type-secondary);
}
.footerButton {
margin-top: _.unit(7);
@include _.flex_row;

View file

@ -97,11 +97,14 @@ const Consent = () => {
title="action.cancel"
type="secondary"
onClick={() => {
window.history.back();
window.location.replace(consentData.redirectUri);
}}
/>
<Button title="action.authorize" onClick={consentHandler} />
</div>
<div className={styles.redirectUri}>
{t('description.redirect_to', { name: consentData.redirectUri })}
</div>
<div className={styles.footerLink}>
{t('description.not_you')}{' '}
<TextLink replace to="/sign-in" text="action.use_another_account" />

View file

@ -92,6 +92,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -81,6 +81,7 @@ const description = {
authorize_agreement: `By authorize the access, you agree to the {{name}}'s <link></link>.`,
not_you: 'Not you?',
user_id: 'User ID: {{id}}',
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -91,6 +91,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -92,6 +92,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -88,6 +88,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -88,6 +88,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -83,6 +83,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -88,6 +88,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -87,6 +87,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -87,6 +87,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -91,6 +91,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -87,6 +87,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -79,6 +79,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -79,6 +79,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -79,6 +79,8 @@ const description = {
not_you: 'Not you?',
/** UNTRANSLATED */
user_id: 'User ID: {{id}}',
/** UNTRANSLATED */
redirect_to: 'You will be redirected to {{name}}.',
};
export default Object.freeze(description);

View file

@ -62,6 +62,7 @@ export const consentInfoResponseGuard = z.object({
organizations: publicOrganizationGuard.array().optional(),
missingOIDCScope: z.string().array().optional(),
missingResourceScopes: missingResourceScopesGuard.array().optional(),
redirectUri: z.string(),
});
export type ConsentInfoResponse = z.infer<typeof consentInfoResponseGuard>;