Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/client/pages/IframedSignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MinimalLayout } from '@/client/layouts/MinimalLayout';
import ThemedLink from '@/client/components/ThemedLink';
import IframeThemedEmailInput from '../components/IframeThemedEmailInput';
import { disableAutofillBackground } from '../styles/Shared';
import NameInputField from '../components/NameInputField';

export type IframedSignInProps = {
queryParams: QueryParams;
Expand All @@ -38,6 +39,7 @@ export type IframedSignInProps = {
usePasscodeSignIn?: boolean;
hideSocialButtons?: boolean;
focusPasswordField?: boolean;
showNameForm?: boolean;
};

const socialButtonDivider = css`
Expand Down Expand Up @@ -138,6 +140,7 @@ export const IframedSignIn = ({
isReauthenticate = false,
shortRequestId,
hideSocialButtons = false,
showNameForm,
}: IframedSignInProps) => {
const formTrackingName = 'sign-in';

Expand Down Expand Up @@ -202,6 +205,8 @@ export const IframedSignIn = ({
<EmailInput label="Email address" defaultValue={email} />
)}

{showNameForm && <NameInputField></NameInputField>}

<input type="hidden" name="passcode" value="passcode" />
</MainForm>
</MinimalLayout>
Expand Down
4 changes: 3 additions & 1 deletion src/client/pages/IframedSignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IframedSignIn } from './IframedSignIn';
interface Props {
isReauthenticate?: boolean;
hideSocialButtons?: boolean;
showNameForm?: boolean;
}

export const IframedSignInPage = ({
Expand All @@ -19,7 +20,7 @@ export const IframedSignInPage = ({
queryParams,
recaptchaConfig,
} = clientState;
const { email, formError } = pageData;
const { email, showNameForm, formError } = pageData;
const { error: pageError } = globalMessage;
const { recaptchaSiteKey } = recaptchaConfig;

Expand Down Expand Up @@ -48,6 +49,7 @@ export const IframedSignInPage = ({
isReauthenticate={isReauthenticate}
shortRequestId={clientState.shortRequestId}
hideSocialButtons={hideSocialButtons}
showNameForm={showNameForm}
/>
);
};
4 changes: 3 additions & 1 deletion src/server/controllers/signInControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const oktaIdxApiSignInPasscodeController = async ({
loopDetectionFlag?: boolean;
confirmationPagePath?: StartIdxFlowParams['authorizationCodeFlowOptions']['confirmationPagePath'];
}): Promise<void> => {
const { email = '' } = req.body;
const { email = '', firstName, secondName } = req.body;
const referrerUrl = new URL(req.body.ref);
const referrerPath = referrerUrl.pathname;
const emailSentPage = referrerPath.includes('/iframed')
Expand Down Expand Up @@ -249,6 +249,8 @@ export const oktaIdxApiSignInPasscodeController = async ({
extraData: {
flow: 'sign-in-passcode',
appLabel: res.locals.appLabel,
firstName,
lastName: secondName,
},
},
});
Expand Down
2 changes: 2 additions & 0 deletions src/server/lib/okta/idx/interact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export const interact = async (
codeVerifier,
flow: extraData?.flow,
appLabel: extraData?.appLabel,
firstName: extraData?.firstName,
lastName: extraData?.lastName,
},
);
setAuthorizationStateCookie(authState, res);
Expand Down
2 changes: 2 additions & 0 deletions src/server/lib/okta/openid-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface AuthorizationState {
// used to track the flow the user is in for basic metrics/analytics
flow?: UserFlow; // password reset, and email verification flows outside of create account
appLabel?: string; // used to track the app used to start the flow
firstName?: string; // used to persist the first name during the signin flow, so that we can set it after login
lastName?: string; // used to persist the last name during the signin flow, so that we can set it after login
};
}

Expand Down
10 changes: 10 additions & 0 deletions src/server/routes/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ const authenticationHandler = async (
}
}

// Update the users first and last name if they exist in the authState
if (authState.data?.firstName || authState.data?.lastName) {
await updateUser(sub, {
profile: {
firstName: authState.data.firstName,
lastName: authState.data.lastName,
},
});
}

// clear any existing oauth application cookies if they exist
checkAndDeleteOAuthTokenCookies(req, res);

Expand Down
9 changes: 8 additions & 1 deletion src/server/routes/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ const oktaIdxCreateAccountOrSignIn = async (
req: Request,
res: ResponseWithRequestState,
) => {
const { email = '', isCombinedSigninAndRegisterFlow = false } = req.body;
const {
email = '',
firstName,
secondName,
isCombinedSigninAndRegisterFlow = false,
} = req.body;

const {
queryParams: { appClientId, clientId },
Expand Down Expand Up @@ -406,6 +411,8 @@ const oktaIdxCreateAccountOrSignIn = async (
extraData: {
flow: 'create-account',
appLabel: res.locals.appLabel,
firstName,
lastName: secondName,
},
},
consents,
Expand Down
3 changes: 3 additions & 0 deletions src/server/routes/signIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
pageData: {
email: overrideEmailAddress || email,
focusPasswordField: !!email,
showNameForm: true,
},
globalMessage: {
error: getErrorMessageFromQueryParams(error, error_description),
Expand Down Expand Up @@ -148,6 +149,8 @@
const prepopulatedEmail = prepopulatedEmailParamEncoded
? decodeURIComponent(prepopulatedEmailParamEncoded)
: null;
const showNameFormParamEncoded =

Check failure on line 152 in src/server/routes/signIn.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration

'showNameFormParamEncoded' is assigned a value but never used. Allowed unused vars must match /^_|React|req|res|next|error|idxPaths|Schema$/u
params.has('showNameForm') && params.get('showNameForm') !== 'false';

const html = await handleSigninRender(req, res, prepopulatedEmail);
return res.type('html').send(html);
Expand Down
3 changes: 3 additions & 0 deletions src/shared/model/ClientState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export interface PageData {

// sign in with password specific
focusPasswordField?: boolean;

// iframe specific
showNameForm?: boolean;
}

export interface RecaptchaConfig {
Expand Down
Loading