Update Partner

This commit is contained in:
aditya.siregar 2024-08-15 23:13:33 +07:00
parent 5907802908
commit 6fabd843d2
2 changed files with 6 additions and 3 deletions

View File

@ -103,10 +103,12 @@ type PartnerLicense struct {
func (l *LicenseDB) ToPartnerLicense() PartnerLicense {
now := time.Now()
daysToExpire := int64(l.EndDate.Sub(now).Hours() / 24)
daysToExpire := int64(l.EndDate.Sub(now).Hours() / 24)
var licenseStatus string
if daysToExpire < 0 {
if now.Before(l.StartDate) {
licenseStatus = "INACTIVE"
} else if daysToExpire < 0 {
licenseStatus = "EXPIRED"
} else if daysToExpire <= 30 {
licenseStatus = "EXPIRING_SOON"

View File

@ -73,7 +73,8 @@ func (u *AuthServiceImpl) AuthenticateUser(ctx context.Context, email, password
}
licensePartner = partnerLicense.ToPartnerLicense()
if licensePartner.LicenseStatus == "EXPIRED" {
if licensePartner.LicenseStatus == "EXPIRED"
|| licensePartner.LicenseStatus == "INACTIVE" {
return nil, errors.ErrorInvalidLicense
}
}