mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
feat: pass user agent to connector (#2770)
This commit is contained in:
parent
2a723f01a3
commit
396dce8c3d
3 changed files with 10 additions and 2 deletions
|
@ -28,8 +28,12 @@ export const createSocialAuthorizationUrl = async (
|
|||
|
||||
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
|
||||
|
||||
const {
|
||||
headers: { 'user-agent': userAgent },
|
||||
} = ctx.request;
|
||||
|
||||
return connector.getAuthorizationUri(
|
||||
{ state, redirectUri },
|
||||
{ state, redirectUri, headers: { userAgent } },
|
||||
async (connectorStorage: ConnectorSession) =>
|
||||
assignConnectorSessionResult(ctx, provider, connectorStorage)
|
||||
);
|
||||
|
|
|
@ -52,13 +52,16 @@ export default function socialRoutes<T extends AnonymousRouterLegacy>(
|
|||
}),
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
const {
|
||||
headers: { 'user-agent': userAgent },
|
||||
} = ctx.request;
|
||||
await provider.interactionDetails(ctx.req, ctx.res);
|
||||
const { connectorId, state, redirectUri } = ctx.guard.body;
|
||||
assertThat(state && redirectUri, 'session.insufficient_info');
|
||||
const connector = await getLogtoConnectorById(connectorId);
|
||||
assertThat(connector.type === ConnectorType.Social, 'connector.unexpected_type');
|
||||
const redirectTo = await connector.getAuthorizationUri(
|
||||
{ state, redirectUri },
|
||||
{ state, redirectUri, headers: { userAgent } },
|
||||
async (connectorStorage: ConnectorSession) =>
|
||||
assignConnectorSessionResult(ctx, provider, connectorStorage)
|
||||
);
|
||||
|
|
|
@ -166,6 +166,7 @@ export type GetAuthorizationUri = (
|
|||
payload: {
|
||||
state: string;
|
||||
redirectUri: string;
|
||||
headers?: { userAgent?: string };
|
||||
},
|
||||
setSession?: SetSession
|
||||
) => Promise<string>;
|
||||
|
|
Loading…
Reference in a new issue