Skip to content

Commit 3ca0058

Browse files
authored
Merge pull request #2451 from ORCID/remove-legacy-registration-code
Remove legacy registration code
2 parents 0320c9c + 07bfeaa commit 3ca0058

131 files changed

Lines changed: 1771 additions & 5701 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/app-routing.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const routes: Routes = [
9191
path: ApplicationRoutes.register,
9292
canActivateChild: [LanguageGuard, RegisterGuard],
9393
loadChildren: () =>
94-
import('./register2/register.module').then((m) => m.Register2Module),
94+
import('./register/register.module').then((m) => m.RegisterModule),
9595
},
9696
{
9797
path: ApplicationRoutes.search,
@@ -151,7 +151,7 @@ const routes: Routes = [
151151
matcher: routerReactivation,
152152
canActivateChild: [LanguageGuard, RegisterGuard],
153153
loadChildren: () =>
154-
import('./register2/register.module').then((m) => m.Register2Module),
154+
import('./register/register.module').then((m) => m.RegisterModule),
155155
},
156156
{
157157
path: ApplicationRoutes.selfService,

src/app/cdk/interstitials/affiliations-interstitial/interstitial-component/affiliations-interstitial.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
66
import { OrganizationsService, UserService } from 'src/app/core'
77
import { RecordAffiliationService } from 'src/app/core/record-affiliations/record-affiliations.service'
88
import { RecordService } from 'src/app/core/record/record.service'
9-
import { Register2Service } from 'src/app/core/register2/register2.service'
9+
import { RegisterService } from 'src/app/core/register/register.service'
1010
import { AffiliationsInterstitialComponent } from './affiliations-interstitial.component'
1111
import { EMPTY } from 'rxjs'
1212
import { PlatformInfoService } from 'src/app/cdk/platform-info'
@@ -38,7 +38,7 @@ describe('AffiliationsInterstitialComponent', () => {
3838
},
3939

4040
{
41-
provide: Register2Service,
41+
provide: RegisterService,
4242
useValue: {},
4343
},
4444

src/app/cdk/interstitials/affiliations-interstitial/interstitial-component/affiliations-interstitial.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from 'src/app/constants'
2828
import { dateMonthYearValidator } from 'src/app/shared/validators/date/date.validator'
2929
import { OrganizationsService, UserService } from 'src/app/core'
30-
import { Register2Service } from 'src/app/core/register2/register2.service'
30+
import { RegisterService } from 'src/app/core/register/register.service'
3131
import { AssertionVisibilityString, RequestInfoForm } from 'src/app/types'
3232
import {
3333
Affiliation,
@@ -97,7 +97,7 @@ export class AffiliationsInterstitialComponent implements OnInit, OnDestroy {
9797
private formBuilder: UntypedFormBuilder,
9898
private recordService: RecordService,
9999
private organizationService: OrganizationsService,
100-
private register2Service: Register2Service,
100+
private registerService: RegisterService,
101101
private user: UserService
102102
) {}
103103

@@ -115,7 +115,7 @@ export class AffiliationsInterstitialComponent implements OnInit, OnDestroy {
115115
switchMap((domain: AssertionVisibilityString) => {
116116
if (domain) {
117117
this.userDomainMatched = domain.value
118-
return this.register2Service
118+
return this.registerService
119119
.getEmailCategory(domain.value)
120120
.pipe(map((response) => response.rorId))
121121
}

src/app/cdk/interstitials/affiliations-interstitial/interstitial-dialog-extend/affiliations-interstitial-dialog.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ import {
2222
} from '@angular/material/legacy-dialog'
2323
import { OrganizationsService, UserService } from 'src/app/core'
2424
import { RecordService } from 'src/app/core/record/record.service'
25-
import { RecordCountriesService } from 'src/app/core/record-countries/record-countries.service'
2625
import { RecordAffiliationService } from 'src/app/core/record-affiliations/record-affiliations.service'
27-
import { Register2Service } from 'src/app/core/register2/register2.service'
28-
import { extend } from 'lodash'
26+
import { RegisterService } from 'src/app/core/register/register.service'
27+
2928
import {
3029
BaseInterstitialDialogInput,
3130
BaseInterstitialDialogOutput,
@@ -66,7 +65,7 @@ export class AffiliationsInterstitialDialogComponent extends AffiliationsInterst
6665
formBuilder: UntypedFormBuilder,
6766
recordService: RecordService,
6867
organizationService: OrganizationsService,
69-
register2Service: Register2Service,
68+
registerService: RegisterService,
7069
private dialogRef: MatLegacyDialogRef<
7170
AffiliationsInterstitialDialogComponent,
7271
AffilationsComponentDialogOutput
@@ -80,7 +79,7 @@ export class AffiliationsInterstitialDialogComponent extends AffiliationsInterst
8079
formBuilder,
8180
recordService,
8281
organizationService,
83-
register2Service,
82+
registerService,
8483
user
8584
)
8685
}

src/app/core/register/register.backend-validators.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
import { HttpClient } from '@angular/common/http'
12
import {
2-
UntypedFormGroup,
3-
AsyncValidatorFn,
43
AbstractControl,
4+
AsyncValidatorFn,
5+
UntypedFormGroup,
56
ValidationErrors,
67
} from '@angular/forms'
7-
import { RegisterForm } from 'src/app/types/register.endpoint'
8-
import { Constructor } from 'src/app/types'
98
import { Observable, of } from 'rxjs'
10-
11-
import { retry, catchError, map } from 'rxjs/operators'
12-
import { HttpClient } from '@angular/common/http'
9+
import { catchError, map, retry } from 'rxjs/operators'
10+
import { Constructor } from 'src/app/types'
11+
import { RegisterForm } from 'src/app/types/register.endpoint'
1312
import { ErrorHandlerService } from '../error-handler/error-handler.service'
1413

1514
interface HasHttpClientAndErrorHandler {
@@ -23,7 +22,10 @@ interface HasFormAdapters {
2322
formGroupToFullRegistrationForm(
2423
StepA: UntypedFormGroup,
2524
StepB: UntypedFormGroup,
26-
StepC: UntypedFormGroup
25+
StepC: UntypedFormGroup,
26+
StepC2: UntypedFormGroup,
27+
StepD: UntypedFormGroup,
28+
isReactivation?: boolean
2729
): RegisterForm
2830
}
2931

@@ -160,13 +162,19 @@ export function RegisterBackendValidatorMixin<
160162
StepA: UntypedFormGroup,
161163
StepB: UntypedFormGroup,
162164
StepC: UntypedFormGroup,
165+
StepC2: UntypedFormGroup,
166+
StepD: UntypedFormGroup,
167+
isReactivation?: boolean,
163168
type?: 'shibboleth'
164169
): Observable<RegisterForm> {
165170
const registerForm = this.formGroupToFullRegistrationForm(
166171
StepA,
167172
StepB,
168-
StepC
173+
StepC,
174+
StepC2,
175+
StepD
169176
)
177+
registerForm.isReactivation = isReactivation
170178
return this._http
171179
.post<RegisterForm>(
172180
`${runtimeEnvironment.API_WEB}register.json`,

src/app/core/register/register.form-adapter.ts

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { UntypedFormGroup } from '@angular/forms'
2-
import { RegisterForm } from 'src/app/types/register.endpoint'
3-
import { Value, Visibility } from 'src/app/types/common.endpoint'
42
import { Constructor } from 'src/app/types'
3+
import { Value, Visibility } from 'src/app/types/common.endpoint'
4+
import { RegisterForm } from 'src/app/types/register.endpoint'
55

66
export function RegisterFormAdapterMixin<T extends Constructor<any>>(base: T) {
77
return class RegisterFormAdapter extends base {
@@ -116,18 +116,61 @@ export function RegisterFormAdapterMixin<T extends Constructor<any>>(base: T) {
116116
return value
117117
}
118118

119+
formGroupToAffiliationRegisterForm(formGroup: UntypedFormGroup) {
120+
const value = formGroup.controls['organization'].value
121+
const departmentName = formGroup.controls['departmentName'].value
122+
const roleTitle = formGroup.controls['roleTitle'].value
123+
const startDateGroup = formGroup.controls['startDateGroup'].value
124+
125+
if (typeof value === 'string') {
126+
return { affiliationName: { value } }
127+
} else {
128+
return {
129+
affiliationName: { value: value.value },
130+
disambiguatedAffiliationSourceId: {
131+
value: value.disambiguatedAffiliationIdentifier,
132+
},
133+
orgDisambiguatedId: {
134+
value: value.disambiguatedAffiliationIdentifier,
135+
},
136+
departmentName: { value: departmentName },
137+
roleTitle: { value: roleTitle },
138+
affiliationType: { value: 'employment' },
139+
startDate: {
140+
month: startDateGroup.startDateMonth,
141+
year: startDateGroup.startDateYear,
142+
},
143+
sourceId: { value: value.sourceId },
144+
city: { value: value.city },
145+
region: { value: value.region },
146+
country: { value: value.country },
147+
}
148+
}
149+
}
150+
119151
formGroupToFullRegistrationForm(
120152
StepA: UntypedFormGroup,
121153
StepB: UntypedFormGroup,
122-
StepC: UntypedFormGroup
154+
StepC: UntypedFormGroup,
155+
StepC2: UntypedFormGroup,
156+
StepD: UntypedFormGroup
123157
): RegisterForm {
124-
return {
158+
const value = {
125159
...StepA.value.personal,
126160
...StepB.value.password,
127-
...StepB.value.sendOrcidNews,
128161
...StepC.value.activitiesVisibilityDefault,
129-
...StepC.value.termsOfUse,
130-
...StepC.value.captcha,
162+
...StepD.value.sendOrcidNews,
163+
...StepD.value.termsOfUse,
164+
...StepD.value.captcha,
165+
}
166+
167+
if (StepC2.valid) {
168+
return {
169+
...value,
170+
...StepC2.value.affiliations,
171+
}
172+
} else {
173+
return value
131174
}
132175
}
133176
}

src/app/core/register/register.service.spec.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/app/core/register/register.service.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { HttpClient } from '@angular/common/http'
22
import { Injectable } from '@angular/core'
33
import { UntypedFormGroup } from '@angular/forms'
4-
import { Observable } from 'rxjs'
5-
import { catchError, first, map, retry, switchMap } from 'rxjs/operators'
4+
import { Observable, throwError } from 'rxjs'
5+
import { catchError, first, map, retry, switchMap, tap } from 'rxjs/operators'
66
import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'
77
import { RequestInfoForm } from 'src/app/types'
88
import {
@@ -11,13 +11,14 @@ import {
1111
RegisterForm,
1212
} from 'src/app/types/register.endpoint'
1313

14+
import { ERROR_REPORT } from 'src/app/errors'
15+
import { objectToUrlParameters } from '../../constants'
16+
import { ReactivationLocal } from '../../types/reactivation.local'
1417
import { ErrorHandlerService } from '../error-handler/error-handler.service'
1518
import { UserService } from '../user/user.service'
1619
import { RegisterBackendValidatorMixin } from './register.backend-validators'
1720
import { RegisterFormAdapterMixin } from './register.form-adapter'
18-
import { ERROR_REPORT } from 'src/app/errors'
19-
import { objectToUrlParameters } from '../../constants'
20-
import { ReactivationLocal } from '../../types/reactivation.local'
21+
import { EmailCategoryEndpoint } from 'src/app/types/register.email-category'
2122

2223
// Mixing boiler plate
2324

@@ -76,10 +77,18 @@ export class RegisterService extends _RegisterServiceMixingBase {
7677
.pipe(map((form) => (this.backendRegistrationForm = form)))
7778
}
7879

80+
getEmailCategory(email: string): Observable<EmailCategoryEndpoint> {
81+
return this._http.get<any>(
82+
`${runtimeEnvironment.API_WEB}email-domain/find-category?domain=${email}`
83+
)
84+
}
85+
7986
register(
8087
StepA: UntypedFormGroup,
8188
StepB: UntypedFormGroup,
8289
StepC: UntypedFormGroup,
90+
StepC2: UntypedFormGroup,
91+
StepD: UntypedFormGroup,
8392
reactivation: ReactivationLocal,
8493
requestInfoForm?: RequestInfoForm,
8594
updateUserService = true
@@ -89,7 +98,9 @@ export class RegisterService extends _RegisterServiceMixingBase {
8998
const registerForm = this.formGroupToFullRegistrationForm(
9099
StepA,
91100
StepB,
92-
StepC
101+
StepC,
102+
StepC2,
103+
StepD
93104
)
94105
this.addOauthContext(registerForm, requestInfoForm)
95106
return this._platform.get().pipe(

0 commit comments

Comments
 (0)