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 55
55
"
56
56
>
57
57
< div class ="slide ">
58
- < iframe [src] ="iframeUrlWithToken$ | ngrxPush "> </ iframe >
58
+ < div *ngIf ="iframeUrlWithJWTToken$ | ngrxPush as iframeUrlWithJWTToken ">
59
+ < iframe [src] ="iframeUrlWithJWTToken "> </ iframe >
60
+ </ div >
59
61
</ div >
60
62
</ ng-template >
61
63
</ swiper >
Original file line number Diff line number Diff line change @@ -213,6 +213,22 @@ export class DetailsPage {
213
213
} )
214
214
) ;
215
215
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
+
216
232
readonly isFromSeriesPage$ = this . type$ . pipe ( map ( type => type === 'series' ) ) ;
217
233
218
234
constructor (
Original file line number Diff line number Diff line change 6
6
</ div >
7
7
8
8
< 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 >
13
19
</ ng-template >
Original file line number Diff line number Diff line change 1
1
import { Component } from '@angular/core' ;
2
2
import { DomSanitizer } from '@angular/platform-browser' ;
3
+ import { defer } from 'rxjs' ;
3
4
import { map } from 'rxjs/operators' ;
4
5
import { DiaBackendAuthService } from '../../../../shared/dia-backend/auth/dia-backend-auth.service' ;
5
6
import { BUBBLE_IFRAME_URL } from '../../../../shared/dia-backend/secret' ;
6
7
import { ErrorService } from '../../../../shared/error/error.service' ;
7
8
import { NetworkService } from '../../../../shared/network/network.service' ;
8
- import { isNonNullable } from '../../../../utils/rx-operators/rx-operators' ;
9
9
10
10
@Component ( {
11
11
selector : 'app-explore-tab' ,
12
12
templateUrl : './explore-tab.component.html' ,
13
13
styleUrls : [ './explore-tab.component.scss' ] ,
14
14
} )
15
15
export 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
+ } ) ;
22
23
23
24
readonly networkConnected$ = this . networkService . connected$ ;
24
25
Original file line number Diff line number Diff line change @@ -128,6 +128,18 @@ export class DiaBackendAuthService {
128
128
) ;
129
129
}
130
130
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
+
131
143
private readUser$ ( ) {
132
144
return defer ( ( ) => this . getAuthHeaders ( ) ) . pipe (
133
145
concatMap ( headers =>
@@ -413,6 +425,11 @@ export interface LoginResponse {
413
425
readonly auth_token : string ;
414
426
}
415
427
428
+ export interface QueryJWTTokenResponse {
429
+ readonly access : string ;
430
+ readonly refresh : string ;
431
+ }
432
+
416
433
export interface ReadUserResponse {
417
434
readonly username : string ;
418
435
readonly email : string ;
You can’t perform that action at this time.
0 commit comments