Skip to content

Commit 54a8b02

Browse files
authored
Merge pull request #784 from numbersprotocol/feature-send-user-token-to-cc
Send user's auth token along with URL when opening Capture Club from App
2 parents 1e0e94f + 5436f2b commit 54a8b02

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

src/app/features/home/details/details.page.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,20 @@ export class DetailsPage {
379379
}
380380

381381
private openCaptureClub() {
382-
return this.activeDetailedCapture$
383-
.pipe(
384-
first(),
382+
combineLatest([
383+
this.activeDetailedCapture$.pipe(
385384
switchMap(
386385
activeDetailedCapture => activeDetailedCapture.diaBackendAsset$
387386
),
388-
isNonNullable(),
389-
concatMap(diaBackendAsset =>
387+
isNonNullable()
388+
),
389+
this.diaBackendAuthService.token$,
390+
])
391+
.pipe(
392+
first(),
393+
concatMap(([diaBackendAsset, token]) =>
390394
Browser.open({
391-
url: `https://captureclub.cc/asset?mid=${diaBackendAsset.id}`,
395+
url: `https://captureclub.cc/asset?mid=${diaBackendAsset.id}&token=${token}`,
392396
toolbarColor: '#564dfc',
393397
})
394398
),

src/app/features/home/home.page.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
first,
1313
map,
1414
startWith,
15+
switchMap,
1516
tap,
1617
} from 'rxjs/operators';
1718
import { CameraService } from '../../shared/camera/camera.service';
@@ -196,10 +197,18 @@ export class HomePage {
196197
}
197198

198199
// eslint-disable-next-line class-methods-use-this
199-
async openCaptureClub() {
200-
return Browser.open({
201-
url: 'https://captureclub.cc/',
202-
toolbarColor: '#564dfc',
203-
});
200+
openCaptureClub() {
201+
this.diaBackendAuthService.token$
202+
.pipe(
203+
first(),
204+
switchMap(token =>
205+
Browser.open({
206+
url: `https://captureclub.cc/?token=${token}`,
207+
toolbarColor: '#564dfc',
208+
})
209+
),
210+
untilDestroyed(this)
211+
)
212+
.subscribe();
204213
}
205214
}

0 commit comments

Comments
 (0)