summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-08-16 09:51:45 -0700
committerChristopher Speller <crspeller@gmail.com>2017-08-16 09:51:45 -0700
commit0ab490845aed0ce3b58cbffd8ec35be237abda1c (patch)
tree5310cce7e546f5a03f97245af473b62d382028e8 /app
parent32265df8be5d530f5b79284792afb9451464ad3a (diff)
downloadchat-0ab490845aed0ce3b58cbffd8ec35be237abda1c.tar.gz
chat-0ab490845aed0ce3b58cbffd8ec35be237abda1c.tar.bz2
chat-0ab490845aed0ce3b58cbffd8ec35be237abda1c.zip
PLT-6226 Fixing races with licensing (#7213)
* PLT-6226 Fixing races with licensing * Fixing build issue * Fixing licensing issue * removing commented code
Diffstat (limited to 'app')
-rw-r--r--app/apptestlib.go2
-rw-r--r--app/authentication.go4
-rw-r--r--app/compliance.go6
-rw-r--r--app/diagnostics.go16
-rw-r--r--app/email_batching.go2
-rw-r--r--app/ldap.go4
-rw-r--r--app/license_test.go2
-rw-r--r--app/notification.go4
-rw-r--r--app/post.go6
-rw-r--r--app/user.go2
-rw-r--r--app/web_conn.go2
11 files changed, 25 insertions, 25 deletions
diff --git a/app/apptestlib.go b/app/apptestlib.go
index 0c7086c64..3966bdeea 100644
--- a/app/apptestlib.go
+++ b/app/apptestlib.go
@@ -28,7 +28,7 @@ func SetupEnterprise() *TestHelper {
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
- utils.License.Features.SetDefaults()
+ utils.License().Features.SetDefaults()
NewServer()
InitStores()
StartServer()
diff --git a/app/authentication.go b/app/authentication.go
index 5e1b4461f..b09234d5f 100644
--- a/app/authentication.go
+++ b/app/authentication.go
@@ -102,7 +102,7 @@ func CheckUserAdditionalAuthenticationCriteria(user *model.User, mfaToken string
}
func CheckUserMfa(user *model.User, token string) *model.AppError {
- if !user.MfaActive || !utils.IsLicensed || !*utils.License.Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
+ if !user.MfaActive || !utils.IsLicensed() || !*utils.License().Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
return nil
}
@@ -143,7 +143,7 @@ func checkUserNotDisabled(user *model.User) *model.AppError {
}
func authenticateUser(user *model.User, password, mfaToken string) (*model.User, *model.AppError) {
- ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed && *utils.License.Features.LDAP
+ ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed() && *utils.License().Features.LDAP
if user.AuthService == model.USER_AUTH_SERVICE_LDAP {
if !ldapAvailable {
diff --git a/app/compliance.go b/app/compliance.go
index cb1eece70..5b4f9de67 100644
--- a/app/compliance.go
+++ b/app/compliance.go
@@ -12,7 +12,7 @@ import (
)
func GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError) {
- if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed || !*utils.License.Features.Compliance {
+ if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed() || !*utils.License().Features.Compliance {
return nil, model.NewLocAppError("GetComplianceReports", "ent.compliance.licence_disable.app_error", nil, "")
}
@@ -24,7 +24,7 @@ func GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError
}
func SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppError) {
- if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed || !*utils.License.Features.Compliance || einterfaces.GetComplianceInterface() == nil {
+ if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed() || !*utils.License().Features.Compliance || einterfaces.GetComplianceInterface() == nil {
return nil, model.NewLocAppError("saveComplianceReport", "ent.compliance.licence_disable.app_error", nil, "")
}
@@ -41,7 +41,7 @@ func SaveComplianceReport(job *model.Compliance) (*model.Compliance, *model.AppE
}
func GetComplianceReport(reportId string) (*model.Compliance, *model.AppError) {
- if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed || !*utils.License.Features.Compliance || einterfaces.GetComplianceInterface() == nil {
+ if !*utils.Cfg.ComplianceSettings.Enable || !utils.IsLicensed() || !*utils.License().Features.Compliance || einterfaces.GetComplianceInterface() == nil {
return nil, model.NewLocAppError("downloadComplianceReport", "ent.compliance.licence_disable.app_error", nil, "")
}
diff --git a/app/diagnostics.go b/app/diagnostics.go
index aff223855..2eae5871d 100644
--- a/app/diagnostics.go
+++ b/app/diagnostics.go
@@ -423,17 +423,17 @@ func trackConfig() {
}
func trackLicense() {
- if utils.IsLicensed {
+ if utils.IsLicensed() {
data := map[string]interface{}{
- "customer_id": utils.License.Customer.Id,
- "license_id": utils.License.Id,
- "issued": utils.License.IssuedAt,
- "start": utils.License.StartsAt,
- "expire": utils.License.ExpiresAt,
- "users": *utils.License.Features.Users,
+ "customer_id": utils.License().Customer.Id,
+ "license_id": utils.License().Id,
+ "issued": utils.License().IssuedAt,
+ "start": utils.License().StartsAt,
+ "expire": utils.License().ExpiresAt,
+ "users": *utils.License().Features.Users,
}
- features := utils.License.Features.ToMap()
+ features := utils.License().Features.ToMap()
for featureName, featureValue := range features {
data["feature_"+featureName] = featureValue
}
diff --git a/app/email_batching.go b/app/email_batching.go
index a578daf04..b37963a94 100644
--- a/app/email_batching.go
+++ b/app/email_batching.go
@@ -196,7 +196,7 @@ func sendBatchedEmailNotification(userId string, notifications []*batchedNotific
}
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
- if utils.IsLicensed && *utils.License.Features.EmailNotificationContents {
+ if utils.IsLicensed() && *utils.License().Features.EmailNotificationContents {
emailNotificationContentsType = *utils.Cfg.EmailSettings.EmailNotificationContentsType
}
diff --git a/app/ldap.go b/app/ldap.go
index 1b823dc47..17c24db8f 100644
--- a/app/ldap.go
+++ b/app/ldap.go
@@ -14,7 +14,7 @@ import (
func SyncLdap() {
go func() {
- if utils.IsLicensed && *utils.License.Features.LDAP && *utils.Cfg.LdapSettings.Enable {
+ if utils.IsLicensed() && *utils.License().Features.LDAP && *utils.Cfg.LdapSettings.Enable {
if ldapI := einterfaces.GetLdapInterface(); ldapI != nil {
ldapI.SyncNow()
} else {
@@ -25,7 +25,7 @@ func SyncLdap() {
}
func TestLdap() *model.AppError {
- if ldapI := einterfaces.GetLdapInterface(); ldapI != nil && utils.IsLicensed && *utils.License.Features.LDAP && *utils.Cfg.LdapSettings.Enable {
+ if ldapI := einterfaces.GetLdapInterface(); ldapI != nil && utils.IsLicensed() && *utils.License().Features.LDAP && *utils.Cfg.LdapSettings.Enable {
if err := ldapI.RunTest(); err != nil {
err.StatusCode = 500
return err
diff --git a/app/license_test.go b/app/license_test.go
index a7761b204..07805992a 100644
--- a/app/license_test.go
+++ b/app/license_test.go
@@ -13,7 +13,7 @@ func TestLoadLicense(t *testing.T) {
Setup()
LoadLicense()
- if utils.IsLicensed {
+ if utils.IsLicensed() {
t.Fatal("shouldn't have a valid license")
}
}
diff --git a/app/notification.go b/app/notification.go
index 4fec40040..69bfa3b7a 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -236,7 +236,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
sendPushNotifications := false
if *utils.Cfg.EmailSettings.SendPushNotifications {
pushServer := *utils.Cfg.EmailSettings.PushNotificationServer
- if pushServer == model.MHPNS && (!utils.IsLicensed || !*utils.License.Features.MHPNS) {
+ if pushServer == model.MHPNS && (!utils.IsLicensed() || !*utils.License().Features.MHPNS) {
l4g.Warn(utils.T("api.post.send_notifications_and_forget.push_notification.mhpnsWarn"))
sendPushNotifications = false
} else {
@@ -359,7 +359,7 @@ func sendNotificationEmail(post *model.Post, user *model.User, channel *model.Ch
}
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
- if utils.IsLicensed && *utils.License.Features.EmailNotificationContents {
+ if utils.IsLicensed() && *utils.License().Features.EmailNotificationContents {
emailNotificationContentsType = *utils.Cfg.EmailSettings.EmailNotificationContentsType
}
diff --git a/app/post.go b/app/post.go
index a4b177859..068266120 100644
--- a/app/post.go
+++ b/app/post.go
@@ -233,7 +233,7 @@ func UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError
} else {
oldPost = result.Data.(*model.PostList).Posts[post.Id]
- if utils.IsLicensed {
+ if utils.IsLicensed() {
if *utils.Cfg.ServiceSettings.AllowEditPost == model.ALLOW_EDIT_POST_NEVER && post.Message != oldPost.Message {
err := model.NewAppError("UpdatePost", "api.post.update_post.permissions_denied.app_error", nil, "", http.StatusForbidden)
return nil, err
@@ -255,7 +255,7 @@ func UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError
return nil, err
}
- if utils.IsLicensed {
+ if utils.IsLicensed() {
if *utils.Cfg.ServiceSettings.AllowEditPost == model.ALLOW_EDIT_POST_TIME_LIMIT && model.GetMillis() > oldPost.CreateAt+int64(*utils.Cfg.ServiceSettings.PostEditTimeLimit*1000) && post.Message != oldPost.Message {
err := model.NewAppError("UpdatePost", "api.post.update_post.permissions_time_limit.app_error", map[string]interface{}{"timeLimit": *utils.Cfg.ServiceSettings.PostEditTimeLimit}, "", http.StatusBadRequest)
return nil, err
@@ -503,7 +503,7 @@ func SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bo
paramsList := model.ParseSearchParams(terms)
esInterface := einterfaces.GetElasticsearchInterface()
- if esInterface != nil && *utils.Cfg.ElasticsearchSettings.EnableSearching && utils.IsLicensed && *utils.License.Features.Elasticsearch {
+ if esInterface != nil && *utils.Cfg.ElasticsearchSettings.EnableSearching && utils.IsLicensed() && *utils.License().Features.Elasticsearch {
finalParamsList := []*model.SearchParams{}
for _, params := range paramsList {
diff --git a/app/user.go b/app/user.go
index 426a11bcb..813421a5c 100644
--- a/app/user.go
+++ b/app/user.go
@@ -376,7 +376,7 @@ func GetUserByAuth(authData *string, authService string) (*model.User, *model.Ap
}
func GetUserForLogin(loginId string, onlyLdap bool) (*model.User, *model.AppError) {
- ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed && *utils.License.Features.LDAP
+ ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed() && *utils.License().Features.LDAP
if result := <-Srv.Store.User().GetForLogin(
loginId,
diff --git a/app/web_conn.go b/app/web_conn.go
index 43047a881..24b7166c0 100644
--- a/app/web_conn.go
+++ b/app/web_conn.go
@@ -217,7 +217,7 @@ func (webCon *WebConn) IsAuthenticated() bool {
func (webCon *WebConn) SendHello() {
msg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_HELLO, "", "", webCon.UserId, nil)
- msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.ClientCfgHash, utils.IsLicensed))
+ msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.ClientCfgHash, utils.IsLicensed()))
webCon.Send <- msg
}