Skip to content

Commit

Permalink
fix(connector): fix mock social connector
Browse files Browse the repository at this point in the history
fix mock social connector
  • Loading branch information
simeng-li committed Jul 1, 2024
1 parent a56d0e4 commit a12fc9f
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/connectors/connector-mock-social/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ const getAuthorizationUri: GetAuthorizationUri = async (
{ state, redirectUri, connectorId },
setSession
) => {
await setSession({ state, redirectUri, connectorId });
try {
await setSession({ state, redirectUri, connectorId });
} catch (error: unknown) {
// Ignore the error if the method is not implemented
if (!(error instanceof ConnectorError && error.code === ConnectorErrorCodes.NotImplemented)) {
throw error;
}
}

return `http://mock.social.com/?state=${state}&redirect_uri=${redirectUri}`;
};
Expand All @@ -39,11 +46,17 @@ const getUserInfo: GetUserInfo = async (data, getSession) => {
throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, JSON.stringify(data));
}

const connectorSession = await getSession();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!connectorSession) {
throw new ConnectorError(ConnectorErrorCodes.AuthorizationFailed);
try {
const connectorSession = await getSession();
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!connectorSession) {
throw new ConnectorError(ConnectorErrorCodes.AuthorizationFailed);
}
} catch (error: unknown) {
// Ignore the error if the method is not implemented
if (!(error instanceof ConnectorError && error.code === ConnectorErrorCodes.NotImplemented)) {
throw error;
}
}

const { code, userId, ...rest } = result.data;
Expand Down

0 comments on commit a12fc9f

Please sign in to comment.