1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

Require sub check

This commit is contained in:
Harvey Kandola 2022-03-17 16:31:11 -04:00
parent 77c767a351
commit 67070c3bfc
2 changed files with 37 additions and 30 deletions

View file

@ -88,30 +88,32 @@ type Product struct {
// IsValid returns if subscription is valid using RequestContext.
func (p *Product) IsValid(ctx RequestContext) bool {
return true
// Community edition is always valid.
if p.Edition == CommunityEdition {
return true
}
// if p.Edition == CommunityEdition {
// return true
// }
// Empty means we cannot be valid.
if ctx.Subscription.IsEmpty() {
return false
}
// if ctx.Subscription.IsEmpty() {
// return false
// }
// Enterprise edition is valid if system has loaded up user count by tenant.
if uc, ok := p.UserCount[ctx.OrgID]; ok {
// Enterprise edition is valid if subcription date is greater than now and we have enough users/seats.
if time.Now().UTC().Before(ctx.Subscription.End) && uc <= int(ctx.Subscription.Seats) {
return true
}
} else {
// First 10 is free for Enterprise edition.
if Seats1 == ctx.Subscription.Seats && time.Now().UTC().Before(ctx.Subscription.End) {
return true
}
}
// if uc, ok := p.UserCount[ctx.OrgID]; ok {
// // Enterprise edition is valid if subcription date is greater than now and we have enough users/seats.
// if time.Now().UTC().Before(ctx.Subscription.End) && uc <= int(ctx.Subscription.Seats) {
// return true
// }
// } else {
// // First 10 is free for Enterprise edition.
// if Seats1 == ctx.Subscription.Seats && time.Now().UTC().Before(ctx.Subscription.End) {
// return true
// }
// }
return false
// return false
}
// SubscriptionData holds encrypted data and is unpacked into Subscription.