MM-14626: Make license expiry checks behave how they are meant to. (#10495)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
eaeede66b2
Коммит
c3c8b28eb7
@@ -62,6 +62,10 @@ func (a *App) SaveLicense(licenseBytes []byte) (*model.License, *model.AppError)
|
|||||||
return nil, model.NewAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "", http.StatusBadRequest)
|
return nil, model.NewAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if license != nil && license.IsExpired() {
|
||||||
|
return nil, model.NewAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
if ok := a.SetLicense(license); !ok {
|
if ok := a.SetLicense(license); !ok {
|
||||||
return nil, model.NewAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "", http.StatusBadRequest)
|
return nil, model.NewAppError("addLicense", model.EXPIRED_LICENSE_ERROR, nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
@@ -117,11 +121,9 @@ func (a *App) SetLicense(license *model.License) bool {
|
|||||||
if license != nil {
|
if license != nil {
|
||||||
license.Features.SetDefaults()
|
license.Features.SetDefaults()
|
||||||
|
|
||||||
if !license.IsExpired() {
|
a.Srv.licenseValue.Store(license)
|
||||||
a.Srv.licenseValue.Store(license)
|
a.Srv.clientLicenseValue.Store(utils.GetClientLicense(license))
|
||||||
a.Srv.clientLicenseValue.Store(utils.GetClientLicense(license))
|
return true
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a.Srv.licenseValue.Store((*model.License)(nil))
|
a.Srv.licenseValue.Store((*model.License)(nil))
|
||||||
|
|||||||
@@ -53,15 +53,6 @@ func TestSetLicense(t *testing.T) {
|
|||||||
t.Fatal("license should have worked")
|
t.Fatal("license should have worked")
|
||||||
}
|
}
|
||||||
|
|
||||||
l2 := &model.License{}
|
|
||||||
l2.Features = &model.Features{}
|
|
||||||
l2.Customer = &model.Customer{}
|
|
||||||
l2.StartsAt = model.GetMillis() - 1000
|
|
||||||
l2.ExpiresAt = model.GetMillis() - 100
|
|
||||||
if ok := th.App.SetLicense(l2); ok {
|
|
||||||
t.Fatal("license should have failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
l3 := &model.License{}
|
l3 := &model.License{}
|
||||||
l3.Features = &model.Features{}
|
l3.Features = &model.Features{}
|
||||||
l3.Customer = &model.Customer{}
|
l3.Customer = &model.Customer{}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user