Skip to content

Commit e907beb

Browse files
authored
Merge branch 'main' into lmendoza/update-material-mdc-migration-typography
2 parents fd121c2 + 919c0ce commit e907beb

2 files changed

Lines changed: 50 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v2.115.10 - 2025-06-05
2+
3+
[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.115.9...v2.115.10)
4+
5+
- [#2536](https://github.com/ORCID/orcid-angular/pull/2536): Lmendoza/9820 qa regression oauth and openid tests fail because expected error message for negative scenarios is not displayed
6+
17
## v2.115.9 - 2025-06-05
28

39
[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.115.8...v2.115.9)

src/app/authorize/pages/authorize/authorize.component.ts

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
finalize,
88
first,
99
map,
10+
mapTo,
1011
switchMap,
1112
take,
1213
tap,
@@ -73,41 +74,27 @@ export class AuthorizeComponent {
7374
*/
7475
ngOnInit(): void {
7576
this.loading = true
77+
let currentSession: UserSession | null = null
7678

7779
forkJoin({
7880
platform: this.loadPlatformInfo(),
7981
userSession: this.loadUserSession(),
80-
userRecord: this.recordService.getRecord({}).pipe(
81-
filter((userRecord: UserRecord) => {
82-
return (
83-
!!userRecord &&
84-
!!userRecord?.userInfo &&
85-
!!userRecord?.emails &&
86-
!!userRecord?.affiliations?.length
87-
)
88-
}),
89-
take(1)
90-
),
9182
})
9283
.pipe(
93-
switchMap((record) => {
94-
return this.loginMainInterstitialsManagerService
95-
.checkLoginInterstitials(record.userRecord, {
96-
returnType: 'component',
97-
togglzPrefix: 'OAUTH',
98-
})
99-
.pipe(
100-
take(1),
101-
map((interstitial) => {
102-
this.interstitialComponent = interstitial
103-
}),
104-
switchMap(() => {
105-
return of(record.userSession)
106-
}),
107-
finalize(() => {
108-
this.handleUserSession(record.userSession)
109-
})
110-
)
84+
// Keep a copy of userSession for finalize()
85+
tap(({ userSession }) => (currentSession = userSession)),
86+
87+
// If logged in, fetch record → check interstitials; otherwise skip straight to oauth session handling
88+
switchMap(({ userSession }) =>
89+
userSession.loggedIn
90+
? this.loadRecordAndCheckInterstitials(userSession)
91+
: of(userSession)
92+
),
93+
94+
// Always run this at the end, regardless of path
95+
finalize(() => {
96+
this.handleOauthSession(currentSession)
97+
this.loading = false
11198
})
11299
)
113100
.subscribe()
@@ -194,7 +181,7 @@ export class AuthorizeComponent {
194181
* After loading forkJoin data, decide on final flow:
195182
* show error, show domain interstitial, or show authorization screen.
196183
*/
197-
private handleUserSession(userSession: UserSession): void {
184+
private handleOauthSession(userSession: UserSession): void {
198185
this.oauthSession = userSession.oauthSession
199186

200187
// 1. If the backend returned an error
@@ -226,6 +213,33 @@ export class AuthorizeComponent {
226213
this.loading = false
227214
}
228215

216+
/**
217+
* Fetches a valid UserRecord, then runs checkLoginInterstitials,
218+
* and finally emits the original UserSession.
219+
*/
220+
private loadRecordAndCheckInterstitials(
221+
session: UserSession
222+
): Observable<UserSession> {
223+
return this.recordService.getRecord({}).pipe(
224+
// Only proceed if the record has userInfo, emails, and at least one affiliation
225+
filter((rec: UserRecord) => !!rec && !!rec.userInfo),
226+
take(1),
227+
switchMap((validRecord) =>
228+
this.loginMainInterstitialsManagerService
229+
.checkLoginInterstitials(validRecord, {
230+
returnType: 'component',
231+
togglzPrefix: 'OAUTH',
232+
})
233+
.pipe(
234+
take(1),
235+
tap((interstitial) => (this.interstitialComponent = interstitial)),
236+
// After setting up interstitials, pass the original session back downstream
237+
mapTo(session)
238+
)
239+
)
240+
)
241+
}
242+
229243
/**
230244
* Determines if the user was already authorized based on OAuth session data.
231245
*/

0 commit comments

Comments
 (0)