Skip to content

Commit

Permalink
fix(social): show account linking page for guest users attempting to …
Browse files Browse the repository at this point in the history
…sign in with social
  • Loading branch information
coldlink committed May 23, 2024
1 parent 4c5aadf commit dc4e5e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
28 changes: 23 additions & 5 deletions src/client/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,30 @@ const Links = ({ children }: { children: React.ReactNode }) => (
</div>
);

const getErrorContext = (error: string | undefined) => {
const getErrorContext = (
error: string | undefined,
queryParams: QueryParams,
) => {
if (error === SignInErrors.ACCOUNT_ALREADY_EXISTS) {
return (
<>
We cannot sign you in with your social account credentials. Please enter
your account password below to sign in.
<div>
We cannot sign you in with your social account credentials. Please
enter your account password below to sign in. If you do not know your
password, you can{' '}
<Link
href={buildUrlWithQueryParams('/reset-password', {}, queryParams)}
>
reset it here
</Link>
.
</div>
<br />
<div>
If you are still having trouble, please contact our customer service
team at{' '}
<Link href={locations.SUPPORT_EMAIL_MAILTO}>{SUPPORT_EMAIL}</Link>.
</div>
</>
);
} else if (error === RegistrationErrors.PROVISIONING_FAILURE) {
Expand Down Expand Up @@ -129,7 +147,7 @@ export const SignIn = ({
return (
<MainLayout
errorOverride={pageError}
errorContext={getErrorContext(pageError)}
errorContext={getErrorContext(pageError, queryParams)}
tabs={tabs}
errorSmallMarginBottom={!!pageError}
pageHeader="Sign in"
Expand All @@ -139,7 +157,7 @@ export const SignIn = ({
{showAuthProviderButtons(socialSigninBlocked, queryParams, isJobs)}
<MainForm
formErrorMessageFromParent={formError}
formErrorContextFromParent={getErrorContext(formError)}
formErrorContextFromParent={getErrorContext(formError, queryParams)}
formAction={buildUrlWithQueryParams(
isReauthenticate ? '/reauthenticate' : '/signin',
{},
Expand Down
5 changes: 3 additions & 2 deletions src/server/routes/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,9 @@ router.get(
// and redirect to the sign in page with the social sign in blocked error
if (
callbackParams.error === OpenIdErrors.ACCESS_DENIED &&
callbackParams.error_description ===
OpenIdErrorDescriptions.ACCOUNT_LINKING_DENIED_GROUPS
(callbackParams.error_description ===
OpenIdErrorDescriptions.ACCOUNT_LINKING_DENIED_GROUPS ||
OpenIdErrorDescriptions.USER_STATUS_INVALID)
) {
trackMetric('OAuthAuthorization::Failure');
return res.redirect(
Expand Down
1 change: 1 addition & 0 deletions src/shared/model/OpenIdErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export enum OpenIdErrors {

export enum OpenIdErrorDescriptions {
ACCOUNT_LINKING_DENIED_GROUPS = 'User linking was denied because the user is not in any of the specified groups.',
USER_STATUS_INVALID = 'User status is invalid.',
}

0 comments on commit dc4e5e0

Please sign in to comment.