Skip to content

Commit

Permalink
Hide "Back to sign in" link if feature hideSignOutLinkInMFA or `mfa…
Browse files Browse the repository at this point in the history
…OnlyFlow` is set (#3610)

OKTA-718969 Hide "Back to sign in" link if feature hideSignOutLinkInMFA or mfaOnlyFlow is set
  • Loading branch information
denysoblohin-okta committed Apr 26, 2024
1 parent d511d09 commit 2d81c92
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/v2/view-builder/views/TerminalView.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ const Footer = BaseFooter.extend({
return getReloadPageButtonLink();
}
// If cancel object exists idx response then view would take care of rendering back to sign in link
if (!this.options.appState.hasActionObject('cancel') &&
!this.options.appState.containsMessageWithI18nKey(NO_BACKTOSIGNIN_LINK_VIEWS)) {
const shouldShowBackToSignInLink = !this.options.appState.hasActionObject('cancel') &&
!this.options.appState.containsMessageWithI18nKey(NO_BACKTOSIGNIN_LINK_VIEWS) &&
!this.options.settings.get('features.hideSignOutLinkInMFA') &&
!this.options.settings.get('features.mfaOnlyFlow');
if (shouldShowBackToSignInLink) {
// TODO OKTA-432869 "back to sign in" links to org baseUrl, does not work correctly with embedded widget
return getBackToSignInLink(this.options);
}
Expand Down
25 changes: 23 additions & 2 deletions test/testcafe/spec/TerminalView_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RequestMock, userVariables } from 'testcafe';
import { checkA11y } from '../framework/a11y';
import { renderWidget } from '../framework/shared';
import terminalReturnEmail from '../../../playground/mocks/data/idp/idx/terminal-return-email';
import terminalTransferEmail from '../../../playground/mocks/data/idp/idx/terminal-transfered-email';
import terminalReturnExpiredEmail from '../../../playground/mocks/data/idp/idx/terminal-return-expired-email';
Expand Down Expand Up @@ -91,9 +92,13 @@ const endUserRemediationNoOptionsMock = RequestMock()

fixture('Terminal view');

async function setup(t) {
async function setup(t, widgetOptions) {
const options = widgetOptions ? { render: false } : {};
const terminalPageObject = userVariables.gen3 ? new TerminalPageObjectV3(t) : new TerminalPageObject(t);
await terminalPageObject.navigateToPage();
await terminalPageObject.navigateToPage(options);
if (widgetOptions) {
await renderWidget(widgetOptions);
}
// ensure form has loaded
await t.expect(terminalPageObject.formExists()).eql(true);
return terminalPageObject;
Expand Down Expand Up @@ -182,6 +187,22 @@ async function setup(t) {
});
});

// Back to sign in link is not added if disabled with appropriate features
[
['should not have Back to sign in link if hideSignOutLinkInMFA is true', sessionExpiredMock, {
features: { hideSignOutLinkInMFA: true },
}],
['should not have Back to sign in link if mfaOnlyFlow is true', sessionExpiredMock, {
features: { mfaOnlyFlow: true },
}],
].forEach(([ testTitle, mock, widgetOptions ]) => {
test.requestHooks(mock)(testTitle, async t => {
const terminalViewPage = await setup(t, widgetOptions);
await checkA11y(t);
await t.expect(await terminalViewPage.goBackLinkExists()).notOk();
});
});

test.requestHooks(terminalMultipleErrorsMock)('should render each error message when there are multiple', async t => {
const terminalViewPage = await setup(t);
await checkA11y(t);
Expand Down

0 comments on commit 2d81c92

Please sign in to comment.