fix(server): standalone early access users detection (#5601)
This commit is contained in:
@@ -47,9 +47,7 @@ export class FeatureManagementService {
|
|||||||
return this.feature.listFeatureUsers(FeatureType.EarlyAccess);
|
return this.feature.listFeatureUsers(FeatureType.EarlyAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// check early access by email
|
async isEarlyAccessUser(email: string) {
|
||||||
async canEarlyAccess(email: string) {
|
|
||||||
if (this.config.featureFlags.earlyAccessPreview && !this.isStaff(email)) {
|
|
||||||
const user = await this.prisma.user.findFirst({
|
const user = await this.prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
email,
|
email,
|
||||||
@@ -63,6 +61,12 @@ export class FeatureManagementService {
|
|||||||
return canEarlyAccess;
|
return canEarlyAccess;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// check early access by email
|
||||||
|
async canEarlyAccess(email: string) {
|
||||||
|
if (this.config.featureFlags.earlyAccessPreview && !this.isStaff(email)) {
|
||||||
|
return this.isEarlyAccessUser(email);
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -679,7 +679,7 @@ export class SubscriptionService {
|
|||||||
user: User,
|
user: User,
|
||||||
couponType: CouponType
|
couponType: CouponType
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const earlyAccess = await this.features.canEarlyAccess(user.email);
|
const earlyAccess = await this.features.isEarlyAccessUser(user.email);
|
||||||
if (earlyAccess) {
|
if (earlyAccess) {
|
||||||
try {
|
try {
|
||||||
const coupon = await this.stripe.coupons.retrieve(couponType);
|
const coupon = await this.stripe.coupons.retrieve(couponType);
|
||||||
|
|||||||
Reference in New Issue
Block a user