File tree Expand file tree Collapse file tree 5 files changed +54
-12
lines changed Expand file tree Collapse file tree 5 files changed +54
-12
lines changed Original file line number Diff line number Diff line change 5555 "
5656 >
5757 < div class ="slide ">
58- < iframe [src] ="iframeUrlWithToken$ | ngrxPush "> </ iframe >
58+ < div *ngIf ="iframeUrlWithJWTToken$ | ngrxPush as iframeUrlWithJWTToken ">
59+ < iframe [src] ="iframeUrlWithJWTToken "> </ iframe >
60+ </ div >
5961 </ div >
6062 </ ng-template >
6163 </ swiper >
Original file line number Diff line number Diff line change @@ -213,6 +213,22 @@ export class DetailsPage {
213213 } )
214214 ) ;
215215
216+ readonly iframeUrlWithJWTToken$ = combineLatest ( [
217+ this . activeDetailedCapture$ ,
218+ defer ( ( ) => this . diaBackendAuthService . queryJWTToken$ ( ) ) ,
219+ ] ) . pipe (
220+ distinctUntilChanged ( ) ,
221+ map ( ( [ detailedCapture , token ] ) => {
222+ const params =
223+ `nid=${ detailedCapture . id } ` +
224+ `&token=${ token . access } ` +
225+ `&refresh_token=${ token . refresh } ` +
226+ `&from=mycapture` ;
227+ const url = `${ BUBBLE_IFRAME_URL } /asset_page?${ params } ` ;
228+ return this . sanitizer . bypassSecurityTrustResourceUrl ( url ) ;
229+ } )
230+ ) ;
231+
216232 readonly isFromSeriesPage$ = this . type$ . pipe ( map ( type => type === 'series' ) ) ;
217233
218234 constructor (
Original file line number Diff line number Diff line change 66</ div >
77
88< ng-template #bubbleIframe >
9- < iframe
10- [src] ="bubbleIframeUrl$ | ngrxPush | safeResourceUrl "
11- class ="bubble-iframe "
12- > </ iframe >
9+ < div
10+ *ngIf ="
11+ bubbleIframeUrlWithJWTToken$ | ngrxPush as bubbleIframeUrlWithJWTToken
12+ "
13+ >
14+ < iframe
15+ [src] ="bubbleIframeUrlWithJWTToken | safeResourceUrl "
16+ class ="bubble-iframe "
17+ > </ iframe >
18+ </ div >
1319</ ng-template >
Original file line number Diff line number Diff line change 11import { Component } from '@angular/core' ;
22import { DomSanitizer } from '@angular/platform-browser' ;
3+ import { defer } from 'rxjs' ;
34import { map } from 'rxjs/operators' ;
45import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service' ;
56import { BUBBLE_IFRAME_URL } from '../../../../shared/dia-backend/secret' ;
67import { ErrorService } from '../../../../shared/error/error.service' ;
78import { NetworkService } from '../../../../shared/network/network.service' ;
8- import { isNonNullable } from '../../../../utils/rx-operators/rx-operators' ;
99
1010@Component ( {
1111 selector : 'app-explore-tab' ,
1212 templateUrl : './explore-tab.component.html' ,
1313 styleUrls : [ './explore-tab.component.scss' ] ,
1414} )
1515export class ExploreTabComponent {
16- readonly bubbleIframeUrl$ = this . diaBackendAuthService . token$ . pipe (
17- isNonNullable ( ) ,
18- map ( token => {
19- return `${ BUBBLE_IFRAME_URL } /?token=${ token } ` ;
20- } )
21- ) ;
16+ readonly bubbleIframeUrlWithJWTToken$ = defer ( ( ) => {
17+ return this . diaBackendAuthService . queryJWTToken$ ( ) . pipe (
18+ map ( token => {
19+ return `${ BUBBLE_IFRAME_URL } /?token=${ token . access } &refresh_token=${ token . refresh } ` ;
20+ } )
21+ ) ;
22+ } ) ;
2223
2324 readonly networkConnected$ = this . networkService . connected$ ;
2425
Original file line number Diff line number Diff line change @@ -128,6 +128,18 @@ export class DiaBackendAuthService {
128128 ) ;
129129 }
130130
131+ queryJWTToken$ ( ) {
132+ return defer ( ( ) => this . getAuthHeaders ( ) ) . pipe (
133+ concatMap ( headers => {
134+ return this . httpClient . post < QueryJWTTokenResponse > (
135+ `${ BASE_URL } /api/v3/auth/qjwt/` ,
136+ { } ,
137+ { headers }
138+ ) ;
139+ } )
140+ ) ;
141+ }
142+
131143 private readUser$ ( ) {
132144 return defer ( ( ) => this . getAuthHeaders ( ) ) . pipe (
133145 concatMap ( headers =>
@@ -413,6 +425,11 @@ export interface LoginResponse {
413425 readonly auth_token : string ;
414426}
415427
428+ export interface QueryJWTTokenResponse {
429+ readonly access : string ;
430+ readonly refresh : string ;
431+ }
432+
416433export interface ReadUserResponse {
417434 readonly username : string ;
418435 readonly email : string ;
You can’t perform that action at this time.
0 commit comments