feat: Add inTrial getter method to User model

This commit is contained in:
Faruk AYDIN
2023-04-07 22:35:56 +02:00
parent 7d47793afb
commit 3bfc428dfe
2 changed files with 23 additions and 1 deletions

View File

@@ -126,6 +126,19 @@ 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);
}