Browse Source

Setup API key strategy

pull/4093/head
Thomas Kaul 9 months ago
parent
commit
95c720d7bf
  1. 14
      apps/client/src/app/components/user-account-membership/user-account-membership.component.ts

14
apps/client/src/app/components/user-account-membership/user-account-membership.component.ts

@ -107,15 +107,15 @@ export class UserAccountMembershipComponent implements OnDestroy {
this.dataService this.dataService
.createCheckoutSession({ couponId: this.couponId, priceId: this.priceId }) .createCheckoutSession({ couponId: this.couponId, priceId: this.priceId })
.pipe( .pipe(
switchMap(({ sessionId }: { sessionId: string }) => {
return this.stripeService.redirectToCheckout({ sessionId });
}),
catchError((error) => { catchError((error) => {
this.notificationService.alert({ this.notificationService.alert({
title: error.message title: error.message
}); });
throw error; throw error;
}),
switchMap(({ sessionId }: { sessionId: string }) => {
return this.stripeService.redirectToCheckout({ sessionId });
}) })
) )
.subscribe((result) => { .subscribe((result) => {
@ -133,7 +133,6 @@ export class UserAccountMembershipComponent implements OnDestroy {
this.dataService this.dataService
.postApiKey() .postApiKey()
.pipe( .pipe(
takeUntil(this.unsubscribeSubject),
catchError(() => { catchError(() => {
this.snackBar.open( this.snackBar.open(
'😞 ' + $localize`Could not generate an API key`, '😞 ' + $localize`Could not generate an API key`,
@ -144,7 +143,8 @@ export class UserAccountMembershipComponent implements OnDestroy {
); );
return EMPTY; return EMPTY;
}) }),
takeUntil(this.unsubscribeSubject)
) )
.subscribe(({ apiKey }) => { .subscribe(({ apiKey }) => {
this.notificationService.alert({ this.notificationService.alert({
@ -170,7 +170,6 @@ export class UserAccountMembershipComponent implements OnDestroy {
this.dataService this.dataService
.redeemCoupon(couponCode) .redeemCoupon(couponCode)
.pipe( .pipe(
takeUntil(this.unsubscribeSubject),
catchError(() => { catchError(() => {
this.snackBar.open( this.snackBar.open(
'😞 ' + $localize`Could not redeem coupon code`, '😞 ' + $localize`Could not redeem coupon code`,
@ -181,7 +180,8 @@ export class UserAccountMembershipComponent implements OnDestroy {
); );
return EMPTY; return EMPTY;
}) }),
takeUntil(this.unsubscribeSubject)
) )
.subscribe(() => { .subscribe(() => {
this.snackBarRef = this.snackBar.open( this.snackBarRef = this.snackBar.open(

Loading…
Cancel
Save