Skip to content

Commit

Permalink
Merge branch '2362-okta' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Nov 7, 2024
2 parents 71d8fef + 4d89b35 commit 89962e8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h3 translate>Create a new account</h3>
on-state-change="$ctrl.stateChanged(state)"
on-success="$ctrl.onIdentitySuccess()"
on-failure="$ctrl.onIdentityFailure()"
is-inside-another-modal="true"
></sign-in-modal>
<sign-up-modal
ng-switch-when="sign-up"
Expand Down
3 changes: 2 additions & 1 deletion src/common/components/signInModal/signInModal.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default angular
lastPurchaseId: '<',
onStateChange: '&',
onSuccess: '&',
onFailure: '&'
onFailure: '&',
isInsideAnotherModal: '='
}
})
18 changes: 11 additions & 7 deletions src/common/components/signInModal/signInModal.tpl.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<sign-in-form
on-success="$ctrl.onSuccess()"
on-failure="$ctrl.onFailure()"
last-purchase-id="$ctrl.lastPurchaseId"
on-state-change="$ctrl.stateChanged(state)"
on-sign-up-with-okta="$ctrl.stateChanged('sign-up')"
/>
<div ng-class="{'modal-body': !$ctrl.isInsideAnotherModal }">
<div class="content">
<sign-in-form
on-success="$ctrl.onSuccess()"
on-failure="$ctrl.onFailure()"
last-purchase-id="$ctrl.lastPurchaseId"
on-state-change="$ctrl.stateChanged(state)"
on-sign-up-with-okta="$ctrl.stateChanged('sign-up')"
/>
</div>
</div>
17 changes: 6 additions & 11 deletions src/common/services/session/session.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const Sessions = {
profile: 'cru-profile'
}

export const redirectingIndicator = 'redirectingFromOkta'
export const locationOnLogin = 'locationOnLogin'
export const locationSearchOnLogin = 'locationSearchOnLogin'
export const checkoutSavedDataCookieName = 'checkoutSavedData'
Expand Down Expand Up @@ -99,7 +98,7 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,
}

function signIn (lastPurchaseId) {
setOktaRedirecting()
session.isOktaRedirecting = true;
return Observable.from(internalSignIn(lastPurchaseId))
.map((response) => response ? response.data : response)
.finally(() => {
Expand Down Expand Up @@ -298,7 +297,7 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,

async function internalSignOut (redirectHome = true) {
const oktaSignOut = async () => {
// Add session data so on return to page we can show an explaination to the user about what happened.
// Add session data so on return to page we can show an explanation to the user about what happened.
if (!redirectHome) {
$window.sessionStorage.setItem(forcedUserToLogout, true)
// Save location we need to redirect the user back to
Expand Down Expand Up @@ -398,12 +397,12 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,
}
}

function removeOktaRedirectIndicator () {
$window.sessionStorage.removeItem(redirectingIndicator)
function isOktaRedirecting () {
return session.isOktaRedirecting ?? false
}

function isOktaRedirecting () {
return $window.sessionStorage.getItem(redirectingIndicator)
function removeOktaRedirectIndicator () {
session.isOktaRedirecting = false;
}

function updateCurrentProfile () {
Expand All @@ -419,10 +418,6 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,
}

/* Private Methods */
function setOktaRedirecting () {
$window.sessionStorage.setItem(redirectingIndicator, 'true')
}

function updateCurrentSession () {
const cortexRole = decodeCookie(Sessions.role)
const cruProfile = updateCurrentProfile()
Expand Down
12 changes: 6 additions & 6 deletions src/common/services/session/session.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,20 +401,20 @@ describe('session service', function () {

describe('removeOktaRedirectIndicator', () => {
it('should remove the Okta redirect session storage variable', () => {
$window.sessionStorage.setItem(redirectingIndicator, 'true')
sessionService.session.isOktaRedirecting = true
sessionService.removeOktaRedirectIndicator()
expect($window.sessionStorage.getItem(redirectingIndicator)).toEqual(null)
expect(sessionService.session.isOktaRedirecting).toEqual(false)
})
})

describe('isOktaRedirecting', () => {
it('should be true if the session storage variable is set', () => {
$window.sessionStorage.setItem(redirectingIndicator, 'true')
it('should be true if the session variable is set', () => {
sessionService.session.isOktaRedirecting = true
expect(sessionService.isOktaRedirecting()).toBeTruthy()
})

it('should be false if the session storage variable is not set', () => {
$window.sessionStorage.removeItem(redirectingIndicator)
it('should be false if the session variable is not set', () => {
delete sessionService.session.isOktaRedirecting
expect(sessionService.isOktaRedirecting()).toBeFalsy()
})
})
Expand Down

0 comments on commit 89962e8

Please sign in to comment.