From fc0424cc88a679d20e078e873abfa2ccdf4528b3 Mon Sep 17 00:00:00 2001 From: George Nash Date: Mon, 3 Jun 2024 16:55:14 +0100 Subject: [PATCH] backed out previous change and simplified service method --- .../landing-page/landing-page.component.ts | 87 ++++++++++--------- .../app/landing-page/landing-page.service.ts | 2 +- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/ui/src/app/landing-page/landing-page.component.ts b/ui/src/app/landing-page/landing-page.component.ts index 0ecce3b73..478ab4b8d 100644 --- a/ui/src/app/landing-page/landing-page.component.ts +++ b/ui/src/app/landing-page/landing-page.component.ts @@ -60,56 +60,61 @@ export class LandingPageComponent implements OnInit { processRequest(state_param: string, id_token_fragment: string, access_token_fragment: string) { console.log('process request method, calling this.landingPageService.getOrcidConnectionRecord') - this.landingPageService.getOrcidConnectionRecord(state_param).subscribe((result) => { - console.log('got orcid record result: ', result) + this.landingPageService.getOrcidConnectionRecord(state_param).subscribe({ + next: (result) => { + console.log('got orcid record result: ', result) - this.orcidRecord = result - this.landingPageService.getMemberInfo(state_param).subscribe({ - next: (res: IMember) => { - console.log('got member data') + this.orcidRecord = result + this.landingPageService.getMemberInfo(state_param).subscribe({ + next: (res: IMember) => { + console.log('got member data') - this.clientName = res.clientName - this.clientId = res.clientId - this.salesforceId = res.salesforceId - this.oauthUrl = - this.oauthBaseUrl + - '?response_type=token&redirect_uri=' + - this.redirectUri + - '&client_id=' + - this.clientId + - '&scope=/read-limited /activities/update /person/update openid&prompt=login&state=' + - state_param + this.clientName = res.clientName + this.clientId = res.clientId + this.salesforceId = res.salesforceId + this.oauthUrl = + this.oauthBaseUrl + + '?response_type=token&redirect_uri=' + + this.redirectUri + + '&client_id=' + + this.clientId + + '&scope=/read-limited /activities/update /person/update openid&prompt=login&state=' + + state_param - this.incorrectDataMessage = $localize`:@@landingPage.success.ifYouFind.string:If you find that data added to your ORCID record is incorrect, please contact ${this.clientName}` - this.linkAlreadyUsedMessage = $localize`:@@landingPage.connectionExists.differentUser.string:This authorization link has already been used. Please contact ${this.clientName} for a new authorization link.` - this.allowToUpdateRecordMessage = $localize`:@@landingPage.denied.grantAccess.string:Allow ${this.clientName} to update my ORCID record.` - this.successfullyGrantedMessage = $localize`:@@landingPage.success.youHaveSuccessfully.string:You have successfully granted ${this.clientName} permission to update your ORCID record, and your record has been updated with affiliation information.` + this.incorrectDataMessage = $localize`:@@landingPage.success.ifYouFind.string:If you find that data added to your ORCID record is incorrect, please contact ${this.clientName}` + this.linkAlreadyUsedMessage = $localize`:@@landingPage.connectionExists.differentUser.string:This authorization link has already been used. Please contact ${this.clientName} for a new authorization link.` + this.allowToUpdateRecordMessage = $localize`:@@landingPage.denied.grantAccess.string:Allow ${this.clientName} to update my ORCID record.` + this.successfullyGrantedMessage = $localize`:@@landingPage.success.youHaveSuccessfully.string:You have successfully granted ${this.clientName} permission to update your ORCID record, and your record has been updated with affiliation information.` - // Check if id token exists in URL (user just granted permission) - if (id_token_fragment != null && id_token_fragment !== '') { - console.log('checking submit token') + // Check if id token exists in URL (user just granted permission) + if (id_token_fragment != null && id_token_fragment !== '') { + console.log('checking submit token') - this.checkSubmitToken(id_token_fragment, state_param, access_token_fragment) - } else { - const error = this.getFragmentParameterByName('error') - // Check if user denied permission - if (error != null && error !== '') { - if (error === 'access_denied') { - this.submitUserDenied(state_param) + this.checkSubmitToken(id_token_fragment, state_param, access_token_fragment) + } else { + const error = this.getFragmentParameterByName('error') + // Check if user denied permission + if (error != null && error !== '') { + if (error === 'access_denied') { + this.submitUserDenied(state_param) + } else { + this.showErrorElement(error) + } } else { - this.showErrorElement(error) + this.windowLocationService.updateWindowLocation(this.oauthUrl) } - } else { - this.windowLocationService.updateWindowLocation(this.oauthUrl) } - } - this.startTimer(600) - }, - error: (res: HttpErrorResponse) => { - console.log('error') - }, - }) + this.startTimer(600) + }, + error: (res: HttpErrorResponse) => { + console.log('error') + }, + }) + }, + error: (res: HttpErrorResponse) => { + console.log('error') + }, }) } diff --git a/ui/src/app/landing-page/landing-page.service.ts b/ui/src/app/landing-page/landing-page.service.ts index e18311a9e..4547da134 100644 --- a/ui/src/app/landing-page/landing-page.service.ts +++ b/ui/src/app/landing-page/landing-page.service.ts @@ -27,7 +27,7 @@ export class LandingPageService { getOrcidConnectionRecord(state: string): Observable { const requestUrl = this.recordConnectionUri + state - return this.http.get(requestUrl).pipe(map((response: any) => response.body)) + return this.http.get(requestUrl) } getMemberInfo(state: string): Observable {