@@ -28,13 +28,19 @@ export class PricingComponent {
|
||||
async ngOnInit() {
|
||||
const token = await this.keycloakService.getToken();
|
||||
this.keycloakUser = map2User(token);
|
||||
if (this.id) {
|
||||
this.checkout({ priceId: atob(this.id), email: this.keycloakUser.email, name: `${this.keycloakUser.firstName} ${this.keycloakUser.lastName}` });
|
||||
}
|
||||
if (this.keycloakUser && !this.id) {
|
||||
this.user = await this.userService.getByMail(this.keycloakUser.email);
|
||||
if (this.user.subscriptionId) {
|
||||
if (this.keycloakUser) {
|
||||
if (this.id === 'free') {
|
||||
this.user = await this.userService.getByMail(this.keycloakUser.email);
|
||||
this.user.subscriptionPlan = 'free';
|
||||
await this.userService.save(this.user);
|
||||
this.router.navigate([`/account`]);
|
||||
} else if (this.id) {
|
||||
this.checkout({ priceId: atob(this.id), email: this.keycloakUser.email, name: `${this.keycloakUser.firstName} ${this.keycloakUser.lastName}` });
|
||||
} else if (!this.id) {
|
||||
this.user = await this.userService.getByMail(this.keycloakUser.email);
|
||||
if (this.user.subscriptionId) {
|
||||
this.router.navigate([`/account`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +61,7 @@ export class PricingComponent {
|
||||
redirectUri: `${window.location.origin}/pricing/${btoa(priceId)}`,
|
||||
});
|
||||
} else {
|
||||
this.keycloakService.register({ redirectUri: `${window.location.origin}/account` });
|
||||
this.keycloakService.register({ redirectUri: `${window.location.origin}/pricing/free` });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user