Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EP-2362 - Okta #1080

Open
wants to merge 149 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
a88bdc4
Add Okta login on sign-in page
wrandall22 Jul 20, 2022
f587856
Use Okta sign out.
wrandall22 Jul 20, 2022
fc6ecd2
Use Okta url for downgrade
wrandall22 Jul 20, 2022
4eb1ee8
Use Okta forgot password feature
wrandall22 Jul 20, 2022
f640594
sessionEnforcerService on pages that require login
dr-bizz Mar 6, 2024
5a1d441
Built new registerAccount Modal and page with sign-in & userMatch steps
dr-bizz Mar 6, 2024
157e06e
Scss and small amends
dr-bizz Mar 6, 2024
f33851f
SignOut functions and updates
dr-bizz Mar 6, 2024
6af8436
SignUp functions and updates. UserMatch and verification
dr-bizz Mar 6, 2024
7d74159
SignUp functions and updates. UserMatch and verification
dr-bizz Mar 6, 2024
82c3a7d
Removed authClient.closeSession() from signOutWithoutRedirectToOkta()…
dr-bizz Jan 17, 2024
f7b4d1a
Lint & test fixes and cleaning code up
dr-bizz Mar 6, 2024
5eb1576
Created Session Handle Okta Redirect Service
dr-bizz Mar 6, 2024
ab3b559
Redirect user on signIn, Show correct modals on sign in and on accoun…
dr-bizz Mar 6, 2024
f5b23ba
Removing closeSession() as uses third-party cookies. Create signOut p…
dr-bizz Mar 6, 2024
ffecdbb
During merging some code was incorrectly merged causing errors.
dr-bizz Mar 6, 2024
a550ab1
Merge branch 'main' into 2362-okta
dr-bizz Mar 7, 2024
d05404f
DevServices amendments on Create Account modals
dr-bizz Apr 15, 2024
ecb0144
Changes to Sign-in with Okta Pop-up / Modal
dr-bizz May 3, 2024
84e2566
Changes to Sign-in Page and fixing tests
dr-bizz May 3, 2024
904dadd
Fixing lint issues
dr-bizz May 15, 2024
2bbfdb9
Merge branch 'master' into 2362-okta
dr-bizz May 15, 2024
b5b2b9e
Adding padding to the sign-in button
dr-bizz May 28, 2024
6364f8d
Remove next step names in Next button
dr-bizz May 28, 2024
cadf015
adding styles to sign in modal/form
dr-bizz May 28, 2024
aa418a6
fixup! Adding padding to the sign-in button
dr-bizz May 28, 2024
931f268
Limiting modal width
j2trumpet Jul 2, 2024
018094f
Signup activation modal changes
j2trumpet Jul 2, 2024
f298003
Updating account registration prompt text
j2trumpet Jul 2, 2024
2c7a4b4
Sign-in updates
j2trumpet Jul 2, 2024
9b5a654
White screen behind loading graphic
j2trumpet Jul 2, 2024
67dc291
Removing HTML instead of hiding w/ CSS plus centering button
j2trumpet Jul 8, 2024
f4b5243
Changing title heading type
j2trumpet Aug 13, 2024
45b347e
Adding margin-top for consistent spacing
j2trumpet Aug 13, 2024
2e458c1
Removing cart item count from account creation screens
j2trumpet Aug 13, 2024
b39379d
Responsive register account modal
j2trumpet Aug 13, 2024
d97ab31
Use dev1 okta for OIE testing
wrandall22 Aug 21, 2024
1ff331a
Revert "Use dev1 okta for OIE testing"
wrandall22 Aug 21, 2024
6127065
Updating Email Verification Screen content
j2trumpet Aug 22, 2024
14d9f52
Hiding progress bar on first step of user match screens
j2trumpet Aug 22, 2024
6a7da4f
Adding translate properties
j2trumpet Aug 30, 2024
211b254
Refining modal close button
j2trumpet Sep 3, 2024
a035561
Fixing issue of modals getting cut off on the side
j2trumpet Sep 4, 2024
894bf58
Fixing email verification screen on mobile
j2trumpet Sep 5, 2024
f4fa86e
Deleting unnecessary HTML/CSS + cleanup
j2trumpet Sep 5, 2024
1bcf9cd
Updating Okta help text
j2trumpet Sep 5, 2024
263a790
Fixing mobile sign-in modal
j2trumpet Sep 6, 2024
011c1c9
Fixing Guest Checkout vs. Sign-in Page responsiveness
j2trumpet Sep 6, 2024
39e1cc6
Configure against cru.oktapreview for non-production environments
wrandall22 Sep 10, 2024
5d9dae6
Updating re-fetch/refresh text
j2trumpet Oct 4, 2024
cbb6b9a
Fix padding on sign-in-modal
dr-bizz Nov 6, 2024
4d89b35
No longer store isOktaRedirecting on the session but the local sessio…
dr-bizz Nov 6, 2024
04ef183
fix lintint issues
dr-bizz Nov 8, 2024
f5e8474
Prevent loading icon and text from showing up if the user clicks sign…
dr-bizz Nov 8, 2024
fb99aac
adding better UX to the create account by allow users to enter detail…
dr-bizz Nov 8, 2024
58844c6
Update Text on last step on registration.
dr-bizz Nov 11, 2024
893f0ae
Swapping 2 modals. When the user returns to the Give site after they …
dr-bizz Nov 11, 2024
373cc80
Merge branch 'master' into 2362-okta
dr-bizz Nov 11, 2024
3cd5088
Removing Signing in loading text when not fully registered.
dr-bizz Nov 11, 2024
3f7680b
Fixing test on signIn
dr-bizz Nov 12, 2024
5b1d6bd
updating packages
dr-bizz Nov 12, 2024
4429ea6
fixup! Swapping 2 modals. When the user returns to the Give site afte…
dr-bizz Nov 12, 2024
671b916
Adding @okta/okta-signin-widget package
dr-bizz Dec 4, 2024
591d119
Setting up webpack to handle CSS, images and labels from okta sign in…
dr-bizz Dec 4, 2024
adf26cc
Updating webpack to copy the latest assets from the Okta sign-in-widg…
dr-bizz Dec 6, 2024
cfb74a7
Fix all tests since we are using okta signin widget that uses the bro…
dr-bizz Dec 6, 2024
da52059
fixup! Updating webpack to copy the latest assets from the Okta sign-…
dr-bizz Dec 10, 2024
aafb62f
Adding Okta sign in widget to the sign up modal
dr-bizz Dec 10, 2024
e416738
using angular $window. Also no longer copying rootScope & scope
dr-bizz Dec 16, 2024
2026b6f
Adding a back button onto the registration form
dr-bizz Dec 17, 2024
c485765
Allow the user to go back to the sign in page
dr-bizz Dec 17, 2024
9bab4b3
Simplifying the sign up form and retaining the values entered by the …
dr-bizz Dec 17, 2024
63fc987
Update variable names and use checkoutSavedData
dr-bizz Jan 7, 2025
8008737
Ensure we are saving the correct savedCheckoutData and we are using i…
dr-bizz Jan 7, 2025
9ce363a
Using scope instead of rootScope
dr-bizz Jan 7, 2025
cc39187
Using component variable instead of $window
dr-bizz Jan 7, 2025
44ff6d5
removing old code that we no longer require. Manly the signUpActivati…
dr-bizz Jan 7, 2025
5cfb03f
convert login functions to use Observables instead of async/await
dr-bizz Jan 8, 2025
49dc1f7
Removing $scope.apply since now we're using an Observable for signIn,…
dr-bizz Jan 8, 2025
0acabd2
convert logout functions to use Observables instead of async/await
dr-bizz Jan 8, 2025
3251105
fixup! Ensure we are saving the correct savedCheckoutData and we are …
dr-bizz Jan 8, 2025
dba47ba
fixup! convert login functions to use Observables instead of async/await
dr-bizz Jan 8, 2025
7ca584b
fixup! removing old code that we no longer require. Manly the signUpA…
dr-bizz Jan 8, 2025
9fed4e5
fixup! Using scope instead of rootScope
dr-bizz Jan 8, 2025
8dba24d
Fix typo and simplify selector
canac Jan 7, 2025
774a86d
Fix whitespace
canac Jan 7, 2025
0eadb32
Add organization fields onto sign up
dr-bizz Jan 10, 2025
efdca43
Merge branch '2362-okta' into 2362-okta-daniel
dr-bizz Jan 10, 2025
a794e73
Revert changes on contactInfo as we no longer need to use this form d…
dr-bizz Jan 10, 2025
ac8b27a
fixup! Add organization fields onto sign up
dr-bizz Jan 10, 2025
76d314b
Simplifying thew loadDonorDetails function
dr-bizz Jan 13, 2025
dd2ab13
Remove unused binding
canac Jan 10, 2025
344f224
Refactor out onStateChange binding to reduce coupling
canac Jan 10, 2025
2febe47
Pass lastPurchaseId to sign in modal
canac Jan 10, 2025
fabbc56
Use sign in modal inside register account modal
canac Jan 10, 2025
4a42979
Improve and document modal size logic
canac Jan 13, 2025
203c89c
Clear redirect indicator after sign in or sign up
canac Jan 13, 2025
ebc0f79
Merge pull request #1132 from CruGlobal/2362-okta-combine-modals
canac Jan 13, 2025
82d02af
Fix formatting
canac Jan 13, 2025
e313043
Replace onStateChange with onSignUp/onSignIn
canac Jan 8, 2025
ba13150
Hide password details untill the password step
dr-bizz Jan 14, 2025
c604528
Save contact info after sign up
canac Jan 8, 2025
2097ab2
Add checkDonorDetails tests
canac Jan 14, 2025
4475d67
Merge pull request #1130 from CruGlobal/2362-okta-save-contact-info
canac Jan 14, 2025
0884cff
Persist errors on the sign up form when switches between steps.
dr-bizz Jan 14, 2025
c2408c4
Merge branch '2362-okta-daniel' into 2362-okta
dr-bizz Jan 14, 2025
53ffa4d
Clean up the signUpModal
dr-bizz Jan 14, 2025
08052bc
Format and lint
canac Jan 14, 2025
b6ac1fc
Fix indentation
canac Jan 14, 2025
f19d43e
Make onSignUpWithOkta optional
canac Jan 14, 2025
f304900
Removing cart total tests from signUp as we no longer use the cart to…
dr-bizz Jan 15, 2025
b96d6b3
Merge branch '2362-okta-daniel' into 2362-okta
dr-bizz Jan 15, 2025
5ea7b6d
Remove unused createAccount method
canac Jan 14, 2025
430b985
Merge pull request #1134 from CruGlobal/2362-okta-combine-signup-modals
canac Jan 15, 2025
7d107b3
Unnest describe blocks
canac Jan 15, 2025
15efa61
Remove extraneous </div> tag
canac Jan 15, 2025
2409e61
Adjust indentation
canac Jan 15, 2025
dd71485
Make title capitalization consistent
canac Jan 15, 2025
cee7258
Making a registerAccount Modal that is nonDismissible.
dr-bizz Jan 15, 2025
b215dc5
I have reverted signIn to it's prior state. This is because we no lon…
dr-bizz Jan 16, 2025
d1ef17e
Adding page to handle the redirect from okta and authenticate user an…
dr-bizz Jan 16, 2025
e2ecefb
Merge branch '2362-okta-daniel' into 2362-okta
dr-bizz Jan 16, 2025
84c21fe
Skip contact info modal when registration-state is matched
canac Jan 15, 2025
feceba4
Remove redundant call to checkDonorDetails
canac Jan 15, 2025
db19e84
Fix modal title while loading donor details
canac Jan 15, 2025
f49f428
Merge pull request #1135 from CruGlobal/2362-okta-register-account-modal
canac Jan 16, 2025
84c8b95
Remove sessionHandleOktaRedirect
canac Jan 17, 2025
e8496af
Cleaning up files
dr-bizz Jan 22, 2025
58694ba
Adding tests to new Okta Auth Callback page
dr-bizz Jan 22, 2025
e43869b
Upgrading @okta/okta-signin-widget
dr-bizz Jan 22, 2025
416a2aa
Adding signUpModal tests
dr-bizz Jan 23, 2025
5e97251
Merge branch '2362-okta-daniel' into 2362-okta
dr-bizz Jan 23, 2025
a298ffc
Switch back to using $scope instead of $rootScope
canac Jan 27, 2025
1bc1580
Merge pull request #1136 from CruGlobal/2362-okta-remove-redirect-code
canac Jan 27, 2025
b43a36e
fix sign up button test
dr-bizz Jan 27, 2025
89f080f
Merge branch 'master' into 2362-okta
dr-bizz Jan 27, 2025
1bcf51e
Switching to using custom address fields instead of Okta's.
dr-bizz Jan 28, 2025
14d2673
Adding country to the first step so we can reload the form.
dr-bizz Jan 28, 2025
7d155ea
Load country and region/state options
dr-bizz Jan 28, 2025
059a4d3
Inject load error with retry loading country/region button.
dr-bizz Jan 28, 2025
9b74927
removing todo list
dr-bizz Jan 28, 2025
df03173
Esnure lint and tests work
dr-bizz Jan 28, 2025
225a3fa
Fix lints
canac Jan 29, 2025
3cb44df
Move footer buttons from children into user-match-modal
canac Jan 28, 2025
292c2a3
Move footer buttons from user-match-question
canac Jan 28, 2025
c71739a
Move footer buttons from failed-verification-modal
canac Jan 28, 2025
710cf13
Remove footer buttons styles
canac Jan 28, 2025
bc4f652
Remove failed-verification-modal from register-account-modal
canac Jan 28, 2025
823af36
Merge pull request #1139 from CruGlobal/2362-okta-user-match-buttons
canac Jan 29, 2025
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
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ Use yarn for faster installs and to update the yarn lock file: https://yarnpkg.c
### Install & Run

1. `yarn` or `npm install`
2. `yarn start` or `npm start`
3. Browse to [`http://localhost:9000`](http://localhost:9000)
2. `yarn build` or `npm build` _(During the build we copy the latest assets from Okta sign-in-widget package to ensure the sign up form is styled, and shows icons.)_
3. `yarn start` or `npm start`
4. Browse to [`http://localhost:9000`](http://localhost:9000)
Note: For session cookies to work correctly, add an entry to your hosts file for `localhost.cru.org` pointing to `127.0.0.1` and use [`http://localhost.cru.org:9000`](http://localhost.cru.org:9000) for development

### Development Tasks
Expand All @@ -202,3 +203,18 @@ Travis auto-deploys master builds to a pre-prod s3 bucket.
http://devtools.aws.cru.org:8080/view/Give%20Site/job/Give%20NG%20prod%20deploy/ copies
to the live bucket, which backs CloudFront.

## Okta sign-in widget
On the initial set up, [by their instructions](https://www.npmjs.com/package/@okta/okta-signin-widget#using-the-npm-module), we copied the /css, /images and /label folders to our `/assets/okta-sign-in` folder.
When you update the `@okta/okta-signin-widget` package, you may also need to update the `/assets/okta-sign-in` folder.
You can do so by copying the assets from `/node_modules/@okta/okta-signin-widget/dist/`.

Below is a breakdown of the assets you will need to move.

#### `node_modules/@okta/okta-signin-widget/dist/css/`
Move the file `okta-sign-in.min.css` to the folder `/assets/okta-sign-in/css`. At the time of implementing the Okta sign-in widget, there wasn't a need to add the other css files.

#### `node_modules/@okta/okta-signin-widget/dist/img/`
_I highly doubt you will need to move over more images. I didn't want to use webpack for these images, as there are a lot of images we do not need._ But if you need to move them, please move them into the folder `/assets/okta-sign-in/img`.

#### `node_modules/@okta/okta-signin-widget/dist/labels/`
Webpack copies the labels from `@okta/okta-signin-widget` and stores them on our application, so do need to update these.
82 changes: 82 additions & 0 deletions __mocks__/oktaMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
export class OktaAuth {
constructor () {
this.succeed = false
this.loginRedirect = false
this.authenticated = false

this.signOut = jest.fn()
this.signOut.mockImplementation(() => Promise.resolve())

this.token = {
parseFromUrl: jest.fn(),
getWithRedirect: jest.fn()
}

this.token.parseFromUrl.mockImplementation(() => {
if (this.succeed) {
return Promise.resolve({
tokens: { accessToken: 'wee' }
})
} else {
return Promise.reject(new Error('Something went wrong'))
}
})
this.token.getWithRedirect.mockImplementation(() => Promise.resolve())

this.tokenManager = {
setTokens: () => {},
getTokens: () => {
if (this.authenticated && this.succeed) {
return Promise.resolve({
accessToken: {
accessToken: 'wee'
}
})
} else if (!this.succeed) {
return Promise.reject(new Error('Something went wrong'))
}
}
}
}

isLoginRedirect () {
return this.loginRedirect
}

isAuthenticated () {
return Promise.resolve(this.authenticated)
}

shouldSucceed () {
this.succeed = true
}

shouldFail () {
this.succeed = false
}

setupForRedirect () {
this.loginRedirect = true
this.setAuthenticated(true)
}

setAuthenticated (authenticated) {
this.authenticated = authenticated
}

setLoginRedirect (loginRedirect) {
this.loginRedirect = loginRedirect
}

revokeAccessToken () {
return Promise.resolve(true)
}

revokeRefreshToken () {
return Promise.resolve(true)
}

closeSession () {
return Promise.resolve(true)
}
}
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ module.exports = {
'angular',
'angular-mocks',
'jest-date-mock',
'<rootDir>/jest/setup.js'
'<rootDir>/jest/setup.js',
'jest-canvas-mock'
],
moduleNameMapper: {
'^.+\\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js'
'^.+\\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js',
'^@okta/okta-auth-js$': '<rootDir>/__mocks__/oktaMock.js'
},
modulePaths: [
'<rootDir>/src'
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@babel/runtime-corejs2": "^7.25.9",
"@cruglobal/cru-payments": "^1.2.4",
"@datadog/browser-rum": "^5.16.0",
"@okta/okta-signin-widget": "^7.25.1",
"angular": "^1.8.3",
"angular-cookies": "^1.8.2",
"angular-environment": "https://github.com/jonshaffer/angular-environment.git#d3082c06fb16804d324faac9b7e753fd64a44e5d",
Expand Down Expand Up @@ -59,6 +60,7 @@
"css-loader": "^3.2.0",
"html-loader": "^0.5.5",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
wrandall22 marked this conversation as resolved.
Show resolved Hide resolved
"jest-date-mock": "^1.0.7",
"jest-environment-jsdom": "^29.4.2",
"mini-css-extract-plugin": "^0.8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/analytics/analytics.factory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('analytics factory', () => {
price: itemConfig.AMOUNT.toString(),
quantity: '1',
recurring_date: 'September 13, 2023',
testing_transaction: 'false',
testing_transaction: "false",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not make this change.

})
});

Expand Down
3 changes: 2 additions & 1 deletion src/app/branded/branded-checkout.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class BrandedCheckoutController {
this.analyticsFactory.pageLoaded(true)
this.formatDonorDetails()

this.sessionService.signOut().subscribe(() => {
// We want to use signOutWithoutRedirectToOkta, as signout will redirect the user to okta to flush Okta's session data.
this.sessionService.signOutWithoutRedirectToOkta().subscribe(() => {
this.checkoutStep = 'giftContactPayment'
this.fireAnalyticsEvents('contact', 'payment')
// Remove initialLoadComplete session storage. Used on src/common/components/contactInfo/contactInfo.component.js
Expand Down
4 changes: 2 additions & 2 deletions src/app/branded/branded-checkout.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ describe('branded checkout', () => {
})

it('should set initial checkout step and call formatDonorDetails', () => {
jest.spyOn($ctrl.sessionService, 'signOut').mockReturnValue(Observable.of(''))
jest.spyOn($ctrl.sessionService, 'signOutWithoutRedirectToOkta').mockReturnValue(Observable.of(''))
jest.spyOn($ctrl, 'formatDonorDetails').mockImplementation(() => {})
$ctrl.$onInit()

expect($ctrl.sessionService.signOut).toHaveBeenCalled()
expect($ctrl.sessionService.signOutWithoutRedirectToOkta).toHaveBeenCalled()
expect($ctrl.code).toEqual('1234567')
expect($ctrl.tsysService.setDevice).toHaveBeenCalledWith('test-env')
expect($ctrl.checkoutStep).toEqual('giftContactPayment')
Expand Down
34 changes: 23 additions & 11 deletions src/app/checkout/step-3/step-3.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ import angular from 'angular'
import isString from 'lodash/isString'
import { Observable } from 'rxjs/Observable'
import 'rxjs/add/observable/throw'

import displayAddressComponent from 'common/components/display-address/display-address.component'
import displayRateTotals from 'common/components/displayRateTotals/displayRateTotals.component'

import commonService from 'common/services/api/common.service'
import cartService from 'common/services/api/cart.service'
import orderService from 'common/services/api/order.service'
import profileService from 'common/services/api/profile.service'
import sessionService, { SignInEvent } from 'common/services/session/session.service'
import capitalizeFilter from 'common/filters/capitalize.filter'
import desigSrcDirective from 'common/directives/desigSrc.directive'
import { cartUpdatedEvent } from 'common/components/nav/navCart/navCart.component'
import { SignInEvent } from 'common/services/session/session.service'
import { startDate } from 'common/services/giftHelpers/giftDates.service'
import recaptchaComponent from 'common/components/Recaptcha/RecaptchaWrapper'

import template from './step-3.tpl.html'

import analyticsFactory from 'app/analytics/analytics.factory'
import { cartUpdatedEvent } from 'common/components/nav/navCart/navCart.component'
import displayAddressComponent from 'common/components/display-address/display-address.component'
import displayRateTotals from 'common/components/displayRateTotals/displayRateTotals.component'
import template from './step-3.tpl.html'
import recaptchaComponent from 'common/components/Recaptcha/RecaptchaWrapper'
import { recaptchaFailedEvent, submitOrderEvent } from 'app/checkout/cart-summary/cart-summary.component'

const componentName = 'checkoutStep3'

class Step3Controller {
/* @ngInject */
constructor (orderService, $window, $rootScope, $scope, $log, analyticsFactory, cartService, commonService, profileService, envService) {
constructor (orderService, $window, $rootScope, $scope, $log, analyticsFactory, cartService, commonService, profileService, sessionService, envService) {
this.orderService = orderService
this.$window = $window
this.$rootScope = $rootScope
Expand All @@ -38,6 +34,7 @@ class Step3Controller {
this.commonService = commonService
this.startDate = startDate
this.sessionStorage = $window.sessionStorage
this.sessionService = sessionService
this.selfReference = this
this.isBranded = envService.read('isBrandedCheckout')

Expand Down Expand Up @@ -133,6 +130,19 @@ class Step3Controller {
return enableSubmitBtn
}

saveDonorDataForRegistration () {
if (this.donorDetails['registration-state'] !== 'COMPLETED') {
const storeSessionData = {}
storeSessionData.name = { ...this.donorDetails.name }
storeSessionData.mailingAddress = { ...this.donorDetails.mailingAddress }
storeSessionData['spouse-name'] = { ...this.donorDetails['spouse-name'] }
storeSessionData['donor-type'] = this.donorDetails['donor-type']
storeSessionData['organization-name'] = this.donorDetails['organization-name']
storeSessionData['phone-number'] = this.donorDetails['phone-number']
this.sessionService.updateCheckoutSavedData(storeSessionData)
}
}

submitOrder () {
this.submitOrderInternal(this)
}
Expand Down Expand Up @@ -162,6 +172,7 @@ class Step3Controller {
componentInstance.orderService.clearCoverFees()
componentInstance.onSubmitted()
componentInstance.$scope.$emit(cartUpdatedEvent)
componentInstance.saveDonorDataForRegistration()
componentInstance.changeStep({ newStep: 'thankYou' })
},
error => {
Expand Down Expand Up @@ -206,6 +217,7 @@ export default angular
analyticsFactory.name,
cartService.name,
commonService.name,
sessionService.name,
recaptchaComponent.name
])
.component(componentName, {
Expand Down
17 changes: 16 additions & 1 deletion src/app/checkout/step-3/step-3.component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ describe('checkout', () => {
describe('submit single order', () => {
beforeEach(() => {
jest.spyOn(self.controller.$scope, '$emit').mockImplementation(() => {})
jest.spyOn(self.controller.sessionService, 'updateCheckoutSavedData')
})

afterEach(() => {
Expand All @@ -353,13 +354,16 @@ describe('checkout', () => {

it('should submit the order normally if paying with a bank account', () => {
self.controller.bankAccountPaymentDetails = {}
self.controller.donorDetails = {
'registration-state': 'NEW'
}
self.controller.submitOrder()

expect(self.controller.orderService.submit).toHaveBeenCalled()
expect(self.controller.analyticsFactory.purchase).toHaveBeenCalledWith(self.controller.donorDetails, self.controller.cartData, self.coverFeeDecision)
expect(self.controller.orderService.clearCardSecurityCodes).toHaveBeenCalled()
expect(self.controller.changeStep).toHaveBeenCalledWith({ newStep: 'thankYou' })
expect(self.controller.$scope.$emit).toHaveBeenCalledWith(cartUpdatedEvent)
expect(self.controller.sessionService.updateCheckoutSavedData).toHaveBeenCalled()
})

it('should handle an error submitting an order with a bank account', () => {
Expand All @@ -379,6 +383,9 @@ describe('checkout', () => {

it('should submit the order with a CVV if paying with a credit card', () => {
self.controller.creditCardPaymentDetails = {}
self.controller.donorDetails = {
'registration-state': 'MATCHED'
}
self.storedCvv = '1234'
self.coverFeeDecision = true
self.controller.submitOrder()
Expand All @@ -388,9 +395,13 @@ describe('checkout', () => {
expect(self.controller.orderService.clearCardSecurityCodes).toHaveBeenCalled()
expect(self.controller.changeStep).toHaveBeenCalledWith({ newStep: 'thankYou' })
expect(self.controller.$scope.$emit).toHaveBeenCalledWith(cartUpdatedEvent)
expect(self.controller.sessionService.updateCheckoutSavedData).toHaveBeenCalled()
})

it('should submit the order without a CVV if paying with an existing credit card or the cvv in session storage is missing', () => {
self.controller.donorDetails = {
'registration-state': 'COMPLETED'
}
self.controller.creditCardPaymentDetails = {}
self.storedCvv = undefined
self.coverFeeDecision = true
Expand All @@ -401,6 +412,7 @@ describe('checkout', () => {
expect(self.controller.orderService.clearCardSecurityCodes).toHaveBeenCalled()
expect(self.controller.changeStep).toHaveBeenCalledWith({ newStep: 'thankYou' })
expect(self.controller.$scope.$emit).toHaveBeenCalledWith(cartUpdatedEvent)
expect(self.controller.sessionService.updateCheckoutSavedData).not.toHaveBeenCalled()
})

it('should handle an error submitting an order with a credit card', () => {
Expand Down Expand Up @@ -440,6 +452,9 @@ describe('checkout', () => {
})

it('should clear out cover fee data', () => {
self.controller.donorDetails = {
'registration-state': 'NEW'
}
self.controller.creditCardPaymentDetails = {}
self.controller.submitOrder()

Expand Down
18 changes: 12 additions & 6 deletions src/app/designationEditor/designationEditor.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import sessionEnforcerService, {
EnforcerCallbacks,
EnforcerModes
} from 'common/services/session/sessionEnforcer.service'
import { Roles } from 'common/services/session/session.service'
import sessionHandleOktaRedirectService from 'common/services/session/sessionHandleOktaRedirect.service'
import sessionModalService from 'common/services/session/sessionModal.service'
import sessionService, { Roles } from 'common/services/session/session.service'
import designationEditorService from 'common/services/api/designationEditor.service'

import titleModalController from './titleModal/title.modal'
Expand All @@ -38,12 +39,11 @@ const componentName = 'designationEditor'

class DesignationEditorController {
/* @ngInject */
constructor ($scope, $log, $q, $uibModal, $location, $window, $timeout, envService, sessionService, sessionEnforcerService, sessionModalService, designationEditorService) {
this.$scope = $scope
constructor ($log, $q, $uibModal, $location, $window, $rootScope, $timeout, envService, sessionEnforcerService, sessionHandleOktaRedirectService, sessionModalService, designationEditorService) {
this.$log = $log
this.$timeout = $timeout
this.sessionService = sessionService
this.sessionEnforcerService = sessionEnforcerService
this.sessionHandleOktaRedirectService = sessionHandleOktaRedirectService
this.sessionModalService = sessionModalService
this.designationEditorService = designationEditorService

Expand All @@ -56,6 +56,7 @@ class DesignationEditorController {
this.$q = $q
this.$uibModal = $uibModal
this.$window = $window
this.$rootScope = $rootScope
}

$onInit () {
Expand All @@ -67,6 +68,11 @@ class DesignationEditorController {
this.$window.location = '/'
}

this.sessionHandleOktaRedirectService.onHandleOktaRedirect()
this.sessionHandleOktaRedirectService.errorMessageSubject.subscribe((errorMessage) => {
this.errorMessage = errorMessage
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging the err to the this.errorMessage variable was in the original version of this file, so I've added it, but nowhere uses errorMessage so we can take it out unless you think we could use it in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this in the master branch. If it fails, it redirects to the home page. However, I do see $ctrl.errorMessage being used on the sign in form. Would that show this error message?


this.enforcerId = this.sessionEnforcerService([Roles.registered], {
[EnforcerCallbacks.signIn]: () => {
this.getDesignationContent()
Expand Down Expand Up @@ -271,7 +277,7 @@ class DesignationEditorController {
// pick up on the changes. Toggling contentLoaded off then back on will cause the ng-if on
// `.secondaryPhoto` will forcibly recreate the carousel DOM element.
this.contentLoaded = false
this.$scope.$applyAsync(() => {
this.$rootScope.$applyAsync(() => {
this.contentLoaded = true
})
}
Expand Down Expand Up @@ -402,8 +408,8 @@ export default angular
'environment',
'ngSanitize',
commonModule.name,
sessionService.name,
sessionEnforcerService.name,
sessionHandleOktaRedirectService.name,
sessionModalService.name,
designationEditorService.name,
titleModalController.name,
Expand Down
Loading