Skip to content

Commit

Permalink
Removing logs and adding injector code back
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Dec 19, 2023
1 parent 03e20a6 commit 04958ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/common/components/signInForm/signInForm.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SignInFormController {
this.$log = $log
this.$scope = $scope
this.$document = $document
// this.$injector = angular.injector()
this.$injector = angular.injector()
this.sessionService = sessionService
this.gettext = gettext
this.imgDomain = envService.read('imgDomain')
Expand Down Expand Up @@ -44,12 +44,12 @@ class SignInFormController {
this.isSigningIn = true
delete this.errorMessage
this.sessionService.oktaSignIn(this.lastPurchaseId).subscribe(() => {
// const $injector = this.$injector
// if (!$injector.has('sessionService')) {
// $injector.loadNewModules(['sessionService'])
// }
// this.$document[0].body.dispatchEvent(
// new window.CustomEvent('giveSignInSuccess', { bubbles: true, detail: { $injector } }))
const $injector = this.$injector
if (!$injector.has('sessionService')) {
$injector.loadNewModules(['sessionService'])
}
this.$document[0].body.dispatchEvent(
new window.CustomEvent('giveSignInSuccess', { bubbles: true, detail: { $injector } }))
this.onSuccess()
}, error => {
this.isSigningIn = false
Expand Down
26 changes: 13 additions & 13 deletions src/common/components/signInForm/signInForm.component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ describe('signInForm', function () {
expect(bindings.onSuccess).toHaveBeenCalled()
})

// it('adds the sessionService module', () => {
// deferred.resolve({})
// $rootScope.$digest()
// bindings.$injector.has.mockImplementation(() => false)
// bindings.$injector.loadNewModules.mockImplementation(() => {})

// expect(bindings.$document[0].body.dispatchEvent).toHaveBeenCalled();
// const $injector = bindings.$injector

// expect($injector.loadNewModules).toHaveBeenCalledWith(['sessionService'])
// expect(bindings.$document[0].body.dispatchEvent).toHaveBeenCalledWith(
// new window.CustomEvent('giveSignInSuccess', { bubbles: true, detail: { $injector } }))
// })
it('adds the sessionService module', () => {
deferred.resolve({})
$rootScope.$digest()
bindings.$injector.has.mockImplementation(() => false)
bindings.$injector.loadNewModules.mockImplementation(() => {})

expect(bindings.$document[0].body.dispatchEvent).toHaveBeenCalled();
const $injector = bindings.$injector

expect($injector.loadNewModules).toHaveBeenCalledWith(['sessionService'])
expect(bindings.$document[0].body.dispatchEvent).toHaveBeenCalledWith(
new window.CustomEvent('giveSignInSuccess', { bubbles: true, detail: { $injector } }))
})

it('has unknown error signing in', () => {
deferred.reject({ data: { error: 'invalid_grant' } })
Expand Down
3 changes: 0 additions & 3 deletions src/common/services/session/session.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,
}

function handleOktaRedirect (lastPurchaseId) {
console.log('handleOktaRedirect')
if (authClient.isLoginRedirect()) {
return Observable.from(authClient.token.parseFromUrl().then((tokenResponse) => {
authClient.tokenManager.setTokens(tokenResponse.tokens)
Expand All @@ -97,7 +96,6 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,
}

function oktaSignIn (lastPurchaseId) {
console.log('oktaSignIn')
setOktaRedirecting()
return Observable.from(internalSignIn(lastPurchaseId))
.map((response) => response ? response.data : response)
Expand All @@ -108,7 +106,6 @@ const session = /* @ngInject */ function ($cookies, $rootScope, $http, $timeout,

async function internalSignIn (lastPurchaseId) {
const isAuthenticated = await authClient.isAuthenticated()
console.log('internalSignIn', isAuthenticated)
if (!isAuthenticated) {
// Save marketing search queries as they are lost on redirect
$window.sessionStorage.setItem('locationSearchOnLogin', $window.location.search)
Expand Down

0 comments on commit 04958ef

Please sign in to comment.