feat: Implement getTrialStatus graphQL query
This commit is contained in:
@@ -126,19 +126,6 @@ class User extends Base {
|
||||
},
|
||||
});
|
||||
|
||||
get inTrial() {
|
||||
if (!this.trialExpiryDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const expiryDate = DateTime.fromJSDate(
|
||||
this.trialExpiryDate as unknown as Date
|
||||
);
|
||||
const now = DateTime.now();
|
||||
|
||||
return now < expiryDate;
|
||||
}
|
||||
|
||||
login(password: string) {
|
||||
return bcrypt.compare(password, this.password);
|
||||
}
|
||||
@@ -178,6 +165,29 @@ class User extends Base {
|
||||
this.trialExpiryDate = DateTime.now().plus({ days: 30 }).toISODate();
|
||||
}
|
||||
|
||||
async inTrial() {
|
||||
if (!appConfig.isCloud) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.trialExpiryDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const subscription = await this.$relatedQuery('currentSubscription');
|
||||
|
||||
if (subscription?.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const expiryDate = DateTime.fromJSDate(
|
||||
this.trialExpiryDate as unknown as Date
|
||||
);
|
||||
const now = DateTime.now();
|
||||
|
||||
return now < expiryDate;
|
||||
}
|
||||
|
||||
async $beforeInsert(queryContext: QueryContext) {
|
||||
await super.$beforeInsert(queryContext);
|
||||
await this.generateHash();
|
||||
|
Reference in New Issue
Block a user