@@ -83,17 +83,6 @@ func applyIPFilters(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
|
|
||||||
c.App.Srv().Go(func() {
|
|
||||||
initiatingUser, err := c.App.Srv().Store().User().GetProfileByIds(context.Background(), []string{c.AppContext.Session().UserId}, nil, true)
|
|
||||||
if err != nil {
|
|
||||||
mlog.Error("Failed to get initiating user", mlog.Err(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
users, err := c.App.Srv().Store().User().GetSystemAdminProfiles()
|
|
||||||
if err != nil {
|
|
||||||
mlog.Error("Failed to get system admins", mlog.Err(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
cloudWorkspaceOwnerEmailAddress := ""
|
cloudWorkspaceOwnerEmailAddress := ""
|
||||||
if c.App.License().IsCloud() {
|
if c.App.License().IsCloud() {
|
||||||
portalUserCustomer, cErr := c.App.Cloud().GetCloudCustomer(c.AppContext.Session().UserId)
|
portalUserCustomer, cErr := c.App.Cloud().GetCloudCustomer(c.AppContext.Session().UserId)
|
||||||
@@ -105,12 +94,23 @@ func applyIPFilters(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
initiatingUser, err := c.App.Srv().Store().User().GetProfileByIds(context.Background(), []string{c.AppContext.Session().UserId}, nil, true)
|
||||||
|
if err != nil {
|
||||||
|
mlog.Error("Failed to get initiating user", mlog.Err(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
users, err := c.App.Srv().Store().User().GetSystemAdminProfiles()
|
||||||
|
if err != nil {
|
||||||
|
mlog.Error("Failed to get system admins", mlog.Err(err))
|
||||||
|
}
|
||||||
|
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
if err = c.App.Srv().EmailService.SendIPFiltersChangedEmail(user.Email, initiatingUser[0], *c.App.Config().ServiceSettings.SiteURL, *c.App.Config().CloudSettings.CWSURL, user.Locale, cloudWorkspaceOwnerEmailAddress == user.Email); err != nil {
|
if err = c.App.Srv().EmailService.SendIPFiltersChangedEmail(user.Email, initiatingUser[0], *c.App.Config().ServiceSettings.SiteURL, *c.App.Config().CloudSettings.CWSURL, user.Locale, cloudWorkspaceOwnerEmailAddress == user.Email); err != nil {
|
||||||
mlog.Error("Error while sending IP filters changed email", mlog.Err(err))
|
mlog.Error("Error while sending IP filters changed email", mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}()
|
||||||
|
|
||||||
if err := json.NewEncoder(w).Encode(updatedAllowedRanges); err != nil {
|
if err := json.NewEncoder(w).Encode(updatedAllowedRanges); err != nil {
|
||||||
c.Err = model.NewAppError("getIPFilters", "api.context.ip_filtering.get_ip_filters.app_error", nil, err.Error(), http.StatusInternalServerError)
|
c.Err = model.NewAppError("getIPFilters", "api.context.ip_filtering.get_ip_filters.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
@@ -136,20 +136,9 @@ func Test_applyIPFilters(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
lic := &model.License{
|
lic := model.NewTestLicenseSKU(model.LicenseShortSkuEnterprise, "cloud")
|
||||||
Features: &model.Features{
|
lic.Id = "testlicenseid"
|
||||||
CustomPermissionsSchemes: model.NewBool(false),
|
|
||||||
Cloud: model.NewBool(true),
|
|
||||||
},
|
|
||||||
Customer: &model.Customer{
|
|
||||||
Name: "TestName",
|
|
||||||
Email: "test@example.com",
|
|
||||||
},
|
|
||||||
SkuName: "SKU NAME",
|
|
||||||
SkuShortName: model.LicenseShortSkuEnterprise,
|
|
||||||
StartsAt: model.GetMillis() - 1000,
|
|
||||||
ExpiresAt: model.GetMillis() + 100000,
|
|
||||||
}
|
|
||||||
// Initialize the allowedRanges variable
|
// Initialize the allowedRanges variable
|
||||||
t.Run("No license returns 501", func(t *testing.T) {
|
t.Run("No license returns 501", func(t *testing.T) {
|
||||||
os.Setenv("MM_FEATUREFLAGS_CLOUDIPFILTERING", "true")
|
os.Setenv("MM_FEATUREFLAGS_CLOUDIPFILTERING", "true")
|
||||||
@@ -224,6 +213,8 @@ func Test_applyIPFilters(t *testing.T) {
|
|||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
|
th.App.Srv().SetLicense(lic)
|
||||||
|
|
||||||
ipFiltering := &mocks.IPFilteringInterface{}
|
ipFiltering := &mocks.IPFilteringInterface{}
|
||||||
ipFiltering.Mock.On("ApplyIPFilters", mock.Anything).Return(&model.AllowedIPRanges{
|
ipFiltering.Mock.On("ApplyIPFilters", mock.Anything).Return(&model.AllowedIPRanges{
|
||||||
model.AllowedIPRange{
|
model.AllowedIPRange{
|
||||||
@@ -237,7 +228,16 @@ func Test_applyIPFilters(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
th.App.Srv().IPFiltering = ipFiltering
|
th.App.Srv().IPFiltering = ipFiltering
|
||||||
|
|
||||||
th.App.Srv().SetLicense(lic)
|
cloud := &mocks.CloudInterface{}
|
||||||
|
cloud.Mock.On("GetCloudCustomer", mock.Anything).Return(&model.CloudCustomer{
|
||||||
|
CloudCustomerInfo: model.CloudCustomerInfo{Email: "test@localhost"},
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
cloudImpl := th.App.Srv().Cloud
|
||||||
|
defer func() {
|
||||||
|
th.App.Srv().Cloud = cloudImpl
|
||||||
|
}()
|
||||||
|
th.App.Srv().Cloud = cloud
|
||||||
|
|
||||||
th.Client.Login(context.Background(), th.SystemAdminUser.Email, th.SystemAdminUser.Password)
|
th.Client.Login(context.Background(), th.SystemAdminUser.Email, th.SystemAdminUser.Password)
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user