diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-02-07 18:05:23 +0100 |
---|---|---|
committer | Jesús Espino <jespinog@gmail.com> | 2018-02-07 18:05:23 +0100 |
commit | a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e (patch) | |
tree | 985cb699d278f68522b08b60b1e7b84e0bd243fc /api | |
parent | 7941c30117efe1b957ac0458c2f0479e3824196d (diff) | |
parent | 7bd298ceaa24c0721e0acd65692cb2d1ca4983f3 (diff) | |
download | chat-a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e.tar.gz chat-a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e.tar.bz2 chat-a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-1
Diffstat (limited to 'api')
-rw-r--r-- | api/apitestlib.go | 6 | ||||
-rw-r--r-- | api/context.go | 4 | ||||
-rw-r--r-- | api/user.go | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/api/apitestlib.go b/api/apitestlib.go index f53e7b237..dece29b89 100644 --- a/api/apitestlib.go +++ b/api/apitestlib.go @@ -105,7 +105,11 @@ func setupTestHelper(enterprise bool) *TestHelper { if testStore != nil { th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" }) } - th.App.StartServer() + serverErr := th.App.StartServer() + if serverErr != nil { + panic(serverErr) + } + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = prevListenAddress }) api4.Init(th.App, th.App.Srv.Router, false) Init(th.App, th.App.Srv.Router) diff --git a/api/context.go b/api/context.go index 84967659d..b28a24731 100644 --- a/api/context.go +++ b/api/context.go @@ -127,7 +127,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { c.SetSiteURLHeader(app.GetProtocol(r) + "://" + r.Host) w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId) - w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, c.App.ClientConfigHash(), utils.IsLicensed())) + w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, c.App.ClientConfigHash(), c.App.License() != nil)) // Instruct the browser not to display us in an iframe unless is the same origin for anti-clickjacking if !h.isApi { @@ -292,7 +292,7 @@ func (c *Context) UserRequired() { func (c *Context) MfaRequired() { // Must be licensed for MFA and have it configured for enforcement - if !utils.IsLicensed() || !*utils.License().Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication || !*c.App.Config().ServiceSettings.EnforceMultifactorAuthentication { + if license := c.App.License(); license == nil || !*license.Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication || !*c.App.Config().ServiceSettings.EnforceMultifactorAuthentication { return } diff --git a/api/user.go b/api/user.go index a2e06c013..440ea5858 100644 --- a/api/user.go +++ b/api/user.go @@ -1057,7 +1057,7 @@ func updateMfa(c *Context, w http.ResponseWriter, r *http.Request) { } func checkMfa(c *Context, w http.ResponseWriter, r *http.Request) { - if !utils.IsLicensed() || !*utils.License().Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication { + if license := c.App.License(); license == nil || !*license.Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication { rdata := map[string]string{} rdata["mfa_required"] = "false" w.Write([]byte(model.MapToJson(rdata))) |