MM-40817: Use license interface in Channels (#19678)
* MM-40817: Use license interface in Channels https://mattermost.atlassian.net/browse/MM-40817 ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
06c2aa70b0
Коммит
856f9b11af
@@ -1792,7 +1792,7 @@ func updateChannelScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
auditRec.AddMeta("new_scheme_id", *schemeID)
|
auditRec.AddMeta("new_scheme_id", *schemeID)
|
||||||
|
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.UpdateChannelScheme", "api.channel.update_channel_scheme.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.UpdateChannelScheme", "api.channel.update_channel_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1886,7 +1886,7 @@ func channelMembersMinusGroupMembers(c *Context, w http.ResponseWriter, r *http.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func channelMemberCountsByGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
func channelMemberCountsByGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.channelMemberCountsByGroup", "api.channel.channel_member_counts_by_group.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.channelMemberCountsByGroup", "api.channel.channel_member_counts_by_group.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1919,7 +1919,7 @@ func channelMemberCountsByGroup(c *Context, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.GetChannelModerations", "api.channel.get_channel_moderations.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.GetChannelModerations", "api.channel.get_channel_moderations.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1956,7 +1956,7 @@ func getChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func patchChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
func patchChannelModerations(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.patchChannelModerations", "api.channel.patch_channel_moderations.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.patchChannelModerations", "api.channel.patch_channel_moderations.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (api *API) InitCloud() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.getSubscription", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getSubscription", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.license_error", nil, "", http.StatusInternalServerError)
|
c.Err = model.NewAppError("Api4.changeSubscription", "api.cloud.license_error", nil, "", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ func getSubscriptionStats(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCloudProducts(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getCloudProducts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getCloudProducts", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ func getCloudProducts(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.getCloudCustomer", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getCloudCustomer", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ func getCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
|
func updateCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.updateCloudCustomer", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.updateCloudCustomer", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ func updateCloudCustomer(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateCloudCustomerAddress(c *Context, w http.ResponseWriter, r *http.Request) {
|
func updateCloudCustomerAddress(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.updateCloudCustomerAddress", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.updateCloudCustomerAddress", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ func updateCloudCustomerAddress(c *Context, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) {
|
func createCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.createCustomerPayment", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ func createCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func confirmCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) {
|
func confirmCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.confirmCustomerPayment", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.confirmCustomerPayment", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -327,7 +327,7 @@ func confirmCustomerPayment(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getInvoicesForSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getInvoicesForSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.getInvoicesForSubscription", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getInvoicesForSubscription", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ func getInvoicesForSubscription(c *Context, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getSubscriptionInvoicePDF(c *Context, w http.ResponseWriter, r *http.Request) {
|
func getSubscriptionInvoicePDF(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.getSuscriptionInvoicePDF", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getSuscriptionInvoicePDF", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ func getSubscriptionInvoicePDF(c *Context, w http.ResponseWriter, r *http.Reques
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleCWSWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
func handleCWSWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.handleCWSWebhook", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.handleCWSWebhook", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -466,7 +466,7 @@ func handleCWSWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendAdminUpgradeRequestEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
func sendAdminUpgradeRequestEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmail", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ func sendAdminUpgradeRequestEmail(c *Context, w http.ResponseWriter, r *http.Req
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendAdminUpgradeRequestEmailOnJoin(c *Context, w http.ResponseWriter, r *http.Request) {
|
func sendAdminUpgradeRequestEmailOnJoin(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmailOnJoin", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.sendAdminUpgradeRequestEmailOnJoin", "api.cloud.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func getConfig(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
|
|
||||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
js, jsonErr := cfg.ToJSONFiltered(model.ConfigAccessTagType, model.ConfigAccessTagCloudRestrictable)
|
js, jsonErr := cfg.ToJSONFiltered(model.ConfigAccessTagType, model.ConfigAccessTagCloudRestrictable)
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
c.Err = model.NewAppError("getConfig", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
c.Err = model.NewAppError("getConfig", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||||
@@ -180,7 +180,7 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
c.LogAudit("updateConfig")
|
c.LogAudit("updateConfig")
|
||||||
|
|
||||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
js, jsonErr := cfg.ToJSONFiltered(model.ConfigAccessTagType, model.ConfigAccessTagCloudRestrictable)
|
js, jsonErr := cfg.ToJSONFiltered(model.ConfigAccessTagType, model.ConfigAccessTagCloudRestrictable)
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
c.Err = model.NewAppError("updateConfig", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
c.Err = model.NewAppError("updateConfig", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||||
@@ -306,7 +306,7 @@ func patchConfig(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
js, jsonErr := cfg.ToJSONFiltered(model.ConfigAccessTagType, model.ConfigAccessTagCloudRestrictable)
|
js, jsonErr := cfg.ToJSONFiltered(model.ConfigAccessTagType, model.ConfigAccessTagCloudRestrictable)
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
c.Err = model.NewAppError("patchConfig", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
c.Err = model.NewAppError("patchConfig", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ func linkGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.createGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.createGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -377,7 +377,7 @@ func getGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
syncableType := c.Params.SyncableType
|
syncableType := c.Params.SyncableType
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,7 @@ func getGroupSyncables(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
syncableType := c.Params.SyncableType
|
syncableType := c.Params.SyncableType
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupSyncables", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupSyncables", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -476,7 +476,7 @@ func patchGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.patchGroupSyncable", "api.ldap_groups.license_error", nil, "",
|
c.Err = model.NewAppError("Api4.patchGroupSyncable", "api.ldap_groups.license_error", nil, "",
|
||||||
http.StatusNotImplemented)
|
http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
@@ -542,7 +542,7 @@ func unlinkGroupSyncable(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec.AddMeta("syncable_id", syncableID)
|
auditRec.AddMeta("syncable_id", syncableID)
|
||||||
auditRec.AddMeta("syncable_type", syncableType)
|
auditRec.AddMeta("syncable_type", syncableType)
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.unlinkGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.unlinkGroupSyncable", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -645,7 +645,7 @@ func getGroupStats(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupStats", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupStats", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -685,7 +685,7 @@ func getGroupsByUserId(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupsByUserId", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupsByUserId", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -711,7 +711,7 @@ func getGroupsByChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupsByChannel", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupsByChannel", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -768,7 +768,7 @@ func getGroupsByTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if c.Err != nil {
|
if c.Err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupsByTeam", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupsByTeam", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -810,7 +810,7 @@ func getGroupsAssociatedToChannelsByTeam(c *Context, w http.ResponseWriter, r *h
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*c.App.Srv().License().Features.LDAPGroups {
|
if !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getGroupsAssociatedToChannelsByTeam", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getGroupsAssociatedToChannelsByTeam", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ func (api *API) APILocal(h handlerFunc) http.Handler {
|
|||||||
|
|
||||||
func requireLicense(f handlerFunc) handlerFunc {
|
func requireLicense(f handlerFunc) handlerFunc {
|
||||||
return func(c *Context, w http.ResponseWriter, r *http.Request) {
|
return func(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("", "api.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("", "api.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
12
api4/ldap.go
12
api4/ldap.go
@@ -42,7 +42,7 @@ func (api *API) InitLdap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func syncLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
func syncLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAP {
|
||||||
c.Err = model.NewAppError("Api4.syncLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.syncLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ func syncLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
func testLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAP {
|
||||||
c.Err = model.NewAppError("Api4.testLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.testLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ func getLdapGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.getLdapGroups", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.getLdapGroups", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ func linkLdapGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
auditRec.AddMeta("remote_id", c.Params.RemoteId)
|
auditRec.AddMeta("remote_id", c.Params.RemoteId)
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.linkLdapGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.linkLdapGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ func unlinkLdapGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAPGroups {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAPGroups {
|
||||||
c.Err = model.NewAppError("Api4.unlinkLdapGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.unlinkLdapGroup", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ func migrateIdLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAP {
|
||||||
c.Err = model.NewAppError("Api4.idMigrateLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.idMigrateLdap", "api.ldap_groups.license_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,38 +209,8 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
json.Unmarshal(b, &trialRequest)
|
json.Unmarshal(b, &trialRequest)
|
||||||
if !trialRequest.TermsAccepted {
|
|
||||||
c.Err = model.NewAppError("requestTrialLicense", "api.license.request-trial.bad-request.terms-not-accepted", nil, "", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if trialRequest.Users == 0 {
|
|
||||||
c.Err = model.NewAppError("requestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
currentUser, appErr := c.App.GetUser(c.AppContext.Session().UserId)
|
if err := c.App.Channels().RequestTrialLicense(c.AppContext.Session().UserId, trialRequest.Users, trialRequest.TermsAccepted, trialRequest.ReceiveEmailsAccepted); err != nil {
|
||||||
if appErr != nil {
|
|
||||||
c.Err = appErr
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
trialLicenseRequest := &model.TrialLicenseRequest{
|
|
||||||
ServerID: c.App.TelemetryId(),
|
|
||||||
Name: currentUser.GetDisplayName(model.ShowFullName),
|
|
||||||
Email: currentUser.Email,
|
|
||||||
SiteName: *c.App.Config().TeamSettings.SiteName,
|
|
||||||
SiteURL: *c.App.Config().ServiceSettings.SiteURL,
|
|
||||||
Users: trialRequest.Users,
|
|
||||||
TermsAccepted: trialRequest.TermsAccepted,
|
|
||||||
ReceiveEmailsAccepted: trialRequest.ReceiveEmailsAccepted,
|
|
||||||
}
|
|
||||||
|
|
||||||
if trialLicenseRequest.SiteURL == "" {
|
|
||||||
c.Err = model.NewAppError("RequestTrialLicense", "api.license.request_trial_license.no-site-url.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.App.Srv().RequestTrialLicense(trialLicenseRequest); err != nil {
|
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ func patchRole(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isGuest := oldRole.Name == model.SystemGuestRoleId || oldRole.Name == model.TeamGuestRoleId || oldRole.Name == model.ChannelGuestRoleId
|
isGuest := oldRole.Name == model.SystemGuestRoleId || oldRole.Name == model.TeamGuestRoleId || oldRole.Name == model.ChannelGuestRoleId
|
||||||
if c.App.Srv().License() == nil && patch.Permissions != nil {
|
if c.App.Channels().License() == nil && patch.Permissions != nil {
|
||||||
if isGuest {
|
if isGuest {
|
||||||
c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
@@ -173,7 +173,7 @@ func patchRole(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
*patch.Permissions = model.RemoveDuplicateStrings(*patch.Permissions)
|
*patch.Permissions = model.RemoveDuplicateStrings(*patch.Permissions)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() != nil && isGuest && !*c.App.Srv().License().Features.GuestAccountsPermissions {
|
if c.App.Channels().License() != nil && isGuest && !*c.App.Channels().License().Features.GuestAccountsPermissions {
|
||||||
c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func createScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
auditRec.AddMeta("scheme", scheme)
|
auditRec.AddMeta("scheme", scheme)
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.CustomPermissionsSchemes {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.CustomPermissionsSchemes {
|
||||||
c.Err = model.NewAppError("Api4.CreateScheme", "api.scheme.create_scheme.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.CreateScheme", "api.scheme.create_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ func patchScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec := c.MakeAuditRecord("patchScheme", audit.Fail)
|
auditRec := c.MakeAuditRecord("patchScheme", audit.Fail)
|
||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.CustomPermissionsSchemes {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.CustomPermissionsSchemes {
|
||||||
c.Err = model.NewAppError("Api4.PatchScheme", "api.scheme.patch_scheme.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.PatchScheme", "api.scheme.patch_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ func deleteScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec := c.MakeAuditRecord("deleteScheme", audit.Fail)
|
auditRec := c.MakeAuditRecord("deleteScheme", audit.Fail)
|
||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.CustomPermissionsSchemes {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.CustomPermissionsSchemes {
|
||||||
c.Err = model.NewAppError("Api4.DeleteScheme", "api.scheme.delete_scheme.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.DeleteScheme", "api.scheme.delete_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ func generateSupportPacket(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checking to see if the server has a e10 or e20 license (this feature is only permitted for servers with licenses)
|
// Checking to see if the server has a e10 or e20 license (this feature is only permitted for servers with licenses)
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.generateSupportPacket", "api.no_license", nil, "", http.StatusForbidden)
|
c.Err = model.NewAppError("Api4.generateSupportPacket", "api.no_license", nil, "", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -759,7 +759,7 @@ func getWarnMetricsStatus(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
license := c.App.Srv().License()
|
license := c.App.Channels().License()
|
||||||
if license != nil {
|
if license != nil {
|
||||||
mlog.Debug("License is present, skip.")
|
mlog.Debug("License is present, skip.")
|
||||||
return
|
return
|
||||||
@@ -789,7 +789,7 @@ func sendWarnMetricAckEmail(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
license := c.App.Srv().License()
|
license := c.App.Channels().License()
|
||||||
if license != nil {
|
if license != nil {
|
||||||
mlog.Debug("License is present, skip.")
|
mlog.Debug("License is present, skip.")
|
||||||
return
|
return
|
||||||
@@ -831,7 +831,7 @@ func requestTrialLicenseAndAckWarnMetric(c *Context, w http.ResponseWriter, r *h
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
license := c.App.Srv().License()
|
license := c.App.Channels().License()
|
||||||
if license != nil {
|
if license != nil {
|
||||||
mlog.Debug("License is present, skip.")
|
mlog.Debug("License is present, skip.")
|
||||||
return
|
return
|
||||||
|
|||||||
10
api4/team.go
10
api4/team.go
@@ -1169,7 +1169,7 @@ func teamExists(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("importTeam", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
c.Err = model.NewAppError("importTeam", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1295,7 +1295,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if graceful {
|
if graceful {
|
||||||
cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
|
cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
|
||||||
var invitesOverLimit []*model.EmailInviteWithError
|
var invitesOverLimit []*model.EmailInviteWithError
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud && cloudUserLimit > 0 {
|
||||||
subscription, subErr := c.App.Cloud().GetSubscription(c.AppContext.Session().UserId)
|
subscription, subErr := c.App.Cloud().GetSubscription(c.AppContext.Session().UserId)
|
||||||
if subErr != nil {
|
if subErr != nil {
|
||||||
c.Err = model.NewAppError(
|
c.Err = model.NewAppError(
|
||||||
@@ -1371,7 +1371,7 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
graceful := r.URL.Query().Get("graceful") != ""
|
graceful := r.URL.Query().Get("graceful") != ""
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invate_guests_to_channels.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.InviteGuestsToChannels", "api.team.invate_guests_to_channels.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1416,7 +1416,7 @@ func inviteGuestsToChannels(c *Context, w http.ResponseWriter, r *http.Request)
|
|||||||
if graceful {
|
if graceful {
|
||||||
cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
|
cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
|
||||||
var invitesOverLimit []*model.EmailInviteWithError
|
var invitesOverLimit []*model.EmailInviteWithError
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && cloudUserLimit > 0 && c.IsSystemAdmin() {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud && cloudUserLimit > 0 && c.IsSystemAdmin() {
|
||||||
subscription, err := c.App.Cloud().GetSubscription(c.AppContext.Session().UserId)
|
subscription, err := c.App.Cloud().GetSubscription(c.AppContext.Session().UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = model.NewAppError(
|
c.Err = model.NewAppError(
|
||||||
@@ -1650,7 +1650,7 @@ func updateTeamScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec := c.MakeAuditRecord("updateTeamScheme", audit.Fail)
|
auditRec := c.MakeAuditRecord("updateTeamScheme", audit.Fail)
|
||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
|
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.UpdateTeamScheme", "api.team.update_team_scheme.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.UpdateTeamScheme", "api.team.update_team_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func createTermsOfService(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if license := c.App.Srv().License(); license == nil || !*license.Features.CustomTermsOfService {
|
if license := c.App.Channels().License(); license == nil || !*license.Features.CustomTermsOfService {
|
||||||
c.Err = model.NewAppError("createTermsOfService", "api.create_terms_of_service.custom_terms_of_service_disabled.app_error", nil, "", http.StatusBadRequest)
|
c.Err = model.NewAppError("createTermsOfService", "api.create_terms_of_service.custom_terms_of_service_disabled.app_error", nil, "", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
18
api4/user.go
18
api4/user.go
@@ -135,7 +135,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec.AddMeta("token_type", token.Type)
|
auditRec.AddMeta("token_type", token.Type)
|
||||||
|
|
||||||
if token.Type == app.TokenTypeGuestInvitation {
|
if token.Type == app.TokenTypeGuestInvitation {
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("CreateUserWithToken", "api.user.create_user.guest_accounts.license.app_error", nil, "", http.StatusBadRequest)
|
c.Err = model.NewAppError("CreateUserWithToken", "api.user.create_user.guest_accounts.license.app_error", nil, "", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1389,7 +1389,7 @@ func updateUserRoles(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
for _, roleName := range strings.Fields(newRoles) {
|
for _, roleName := range strings.Fields(newRoles) {
|
||||||
for _, id := range model.NewSystemRoleIDs {
|
for _, id := range model.NewSystemRoleIDs {
|
||||||
if roleName == id {
|
if roleName == id {
|
||||||
if license := c.App.Srv().License(); license == nil || !*license.Features.CustomPermissionsSchemes {
|
if license := c.App.Channels().License(); license == nil || !*license.Features.CustomPermissionsSchemes {
|
||||||
c.Err = model.NewAppError("updateUserRoles", "api.user.update_user_roles.license.app_error", nil, "", http.StatusBadRequest)
|
c.Err = model.NewAppError("updateUserRoles", "api.user.update_user_roles.license.app_error", nil, "", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1830,7 +1830,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
ldapOnly := props["ldap_only"] == "true"
|
ldapOnly := props["ldap_only"] == "true"
|
||||||
|
|
||||||
if *c.App.Config().ExperimentalSettings.ClientSideCertEnable {
|
if *c.App.Config().ExperimentalSettings.ClientSideCertEnable {
|
||||||
if license := c.App.Srv().License(); license == nil || !*license.Features.FutureFeatures {
|
if license := c.App.Channels().License(); license == nil || !*license.Features.FutureFeatures {
|
||||||
c.Err = model.NewAppError("ClientSideCertNotAllowed", "api.user.login.client_side_cert.license.app_error", nil, "", http.StatusBadRequest)
|
c.Err = model.NewAppError("ClientSideCertNotAllowed", "api.user.login.client_side_cert.license.app_error", nil, "", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1864,7 +1864,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
auditRec.AddMeta("user", user)
|
auditRec.AddMeta("user", user)
|
||||||
|
|
||||||
if user.IsGuest() {
|
if user.IsGuest() {
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("login", "api.user.login.guest_accounts.license.error", nil, "", http.StatusUnauthorized)
|
c.Err = model.NewAppError("login", "api.user.login.guest_accounts.license.error", nil, "", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1889,7 +1889,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For context see: https://mattermost.atlassian.net/browse/MM-39583
|
// For context see: https://mattermost.atlassian.net/browse/MM-39583
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
c.App.AttachCloudSessionCookie(c.AppContext, w, r)
|
c.App.AttachCloudSessionCookie(c.AppContext, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1913,7 +1913,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.Cloud {
|
||||||
c.Err = model.NewAppError("loginCWS", "api.user.login_cws.license.error", nil, "", http.StatusUnauthorized)
|
c.Err = model.NewAppError("loginCWS", "api.user.login_cws.license.error", nil, "", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -2683,7 +2683,7 @@ func demoteUserToGuest(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil {
|
if c.App.Channels().License() == nil {
|
||||||
c.Err = model.NewAppError("Api4.demoteUserToGuest", "api.team.demote_user_to_guest.license.error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("Api4.demoteUserToGuest", "api.team.demote_user_to_guest.license.error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -2914,7 +2914,7 @@ func migrateAuthToLDAP(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.LDAP {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.LDAP {
|
||||||
c.Err = model.NewAppError("api.migrateAuthToLDAP", "api.admin.ldap.not_available.app_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("api.migrateAuthToLDAP", "api.admin.ldap.not_available.app_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -2973,7 +2973,7 @@ func migrateAuthToSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.SAML {
|
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.SAML {
|
||||||
c.Err = model.NewAppError("api.migrateAuthToSaml", "api.admin.saml.not_available.app_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("api.migrateAuthToSaml", "api.admin.saml.not_available.app_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,22 +256,7 @@ func (a *App) RequestLicenseAndAckWarnMetric(c *request.Context, warnMetricId st
|
|||||||
return model.NewAppError("RequestLicenseAndAckWarnMetric", "api.license.request_trial_license.fail_get_user_count.app_error", nil, err.Error(), http.StatusBadRequest)
|
return model.NewAppError("RequestLicenseAndAckWarnMetric", "api.license.request_trial_license.fail_get_user_count.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
trialLicenseRequest := &model.TrialLicenseRequest{
|
if err := a.Channels().RequestTrialLicense(c.Session().UserId, int(registeredUsersCount), true, true); err != nil {
|
||||||
ServerID: a.TelemetryId(),
|
|
||||||
Name: currentUser.GetDisplayName(model.ShowFullName),
|
|
||||||
Email: currentUser.Email,
|
|
||||||
SiteName: *a.Config().TeamSettings.SiteName,
|
|
||||||
SiteURL: *a.Config().ServiceSettings.SiteURL,
|
|
||||||
Users: int(registeredUsersCount),
|
|
||||||
TermsAccepted: true,
|
|
||||||
ReceiveEmailsAccepted: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if trialLicenseRequest.SiteURL == "" {
|
|
||||||
return model.NewAppError("RequestLicenseAndAckWarnMetric", "api.license.request_trial_license.no-site-url.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := a.Srv().RequestTrialLicense(trialLicenseRequest); err != nil {
|
|
||||||
// turn off warn metric warning even in case of StartTrial failure
|
// turn off warn metric warning even in case of StartTrial failure
|
||||||
if nerr := a.setWarnMetricsStatusAndNotify(warnMetricId); nerr != nil {
|
if nerr := a.setWarnMetricsStatusAndNotify(warnMetricId); nerr != nil {
|
||||||
return nerr
|
return nerr
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type configSvc interface {
|
|||||||
|
|
||||||
// licenseSvc is added to act as a starting point for future integrated products.
|
// licenseSvc is added to act as a starting point for future integrated products.
|
||||||
// It has the same signature and functionality with the license related APIs of the plugin-api.
|
// It has the same signature and functionality with the license related APIs of the plugin-api.
|
||||||
type licenseSvc interface { // nolint: unused,deadcode
|
type licenseSvc interface {
|
||||||
GetLicense() *model.License
|
GetLicense() *model.License
|
||||||
RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError
|
RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,9 @@ type namer interface {
|
|||||||
|
|
||||||
// Channels contains all channels related state.
|
// Channels contains all channels related state.
|
||||||
type Channels struct {
|
type Channels struct {
|
||||||
srv *Server
|
srv *Server
|
||||||
cfgSvc configSvc
|
cfgSvc configSvc
|
||||||
|
licenseSvc licenseSvc
|
||||||
|
|
||||||
postActionCookieSecret []byte
|
postActionCookieSecret []byte
|
||||||
|
|
||||||
@@ -111,7 +112,10 @@ func NewChannels(s *Server, services map[ServiceKey]interface{}) (*Channels, err
|
|||||||
// 2. Add the field to *Channels
|
// 2. Add the field to *Channels
|
||||||
// 3. Add the service key to the slice.
|
// 3. Add the service key to the slice.
|
||||||
// 4. Add a new case in the switch statement.
|
// 4. Add a new case in the switch statement.
|
||||||
requiredServices := []ServiceKey{ConfigKey}
|
requiredServices := []ServiceKey{
|
||||||
|
ConfigKey,
|
||||||
|
LicenseKey,
|
||||||
|
}
|
||||||
for _, svcKey := range requiredServices {
|
for _, svcKey := range requiredServices {
|
||||||
svc, ok := services[svcKey]
|
svc, ok := services[svcKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -129,8 +133,17 @@ func NewChannels(s *Server, services map[ServiceKey]interface{}) (*Channels, err
|
|||||||
return nil, errors.New("Config service does not contain Name method")
|
return nil, errors.New("Config service does not contain Name method")
|
||||||
}
|
}
|
||||||
ch.cfgSvc = cfgSvc
|
ch.cfgSvc = cfgSvc
|
||||||
|
case LicenseKey:
|
||||||
|
svc, ok := svc.(licenseSvc)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("License service did not satisfy licenseSvc interface")
|
||||||
|
}
|
||||||
|
_, ok = svc.(namer)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("License service does not contain Name method")
|
||||||
|
}
|
||||||
|
ch.licenseSvc = svc
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// We are passing a partially filled Channels struct so that the enterprise
|
// We are passing a partially filled Channels struct so that the enterprise
|
||||||
// methods can have access to app methods.
|
// methods can have access to app methods.
|
||||||
@@ -253,3 +266,12 @@ func (ch *Channels) AddConfigListener(listener func(*model.Config, *model.Config
|
|||||||
func (ch *Channels) RemoveConfigListener(id string) {
|
func (ch *Channels) RemoveConfigListener(id string) {
|
||||||
ch.cfgSvc.RemoveConfigListener(id)
|
ch.cfgSvc.RemoveConfigListener(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ch *Channels) License() *model.License {
|
||||||
|
return ch.licenseSvc.GetLicense()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ch *Channels) RequestTrialLicense(requesterID string, users int, termsAccepted bool, receiveEmailsAccepted bool) *model.AppError {
|
||||||
|
return ch.licenseSvc.RequestTrialLicense(requesterID, users, termsAccepted,
|
||||||
|
receiveEmailsAccepted)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1168,33 +1168,5 @@ func (api *PluginAPI) RequestTrialLicense(requesterID string, users int, termsAc
|
|||||||
return model.NewAppError("RequestTrialLicense", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
return model.NewAppError("RequestTrialLicense", "api.restricted_system_admin", nil, "", http.StatusForbidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !termsAccepted {
|
return api.app.Channels().RequestTrialLicense(requesterID, users, termsAccepted, receiveEmailsAccepted)
|
||||||
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request.terms-not-accepted", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
if users == 0 {
|
|
||||||
return model.NewAppError("RequestTrialLicense", "api.license.request-trial.bad-request", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
requester, err := api.app.GetUser(requesterID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
trialLicenseRequest := &model.TrialLicenseRequest{
|
|
||||||
ServerID: api.app.TelemetryId(),
|
|
||||||
Name: requester.GetDisplayName(model.ShowFullName),
|
|
||||||
Email: requester.Email,
|
|
||||||
SiteName: *api.app.Config().TeamSettings.SiteName,
|
|
||||||
SiteURL: *api.app.Config().ServiceSettings.SiteURL,
|
|
||||||
Users: users,
|
|
||||||
TermsAccepted: termsAccepted,
|
|
||||||
ReceiveEmailsAccepted: receiveEmailsAccepted,
|
|
||||||
}
|
|
||||||
|
|
||||||
if trialLicenseRequest.SiteURL == "" {
|
|
||||||
return model.NewAppError("RequestTrialLicense", "api.license.request_trial_license.no-site-url.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
return api.app.Srv().RequestTrialLicense(trialLicenseRequest)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ func (wc *WebConn) createHelloMessage() *model.WebSocketEvent {
|
|||||||
msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion,
|
msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion,
|
||||||
model.BuildNumber,
|
model.BuildNumber,
|
||||||
wc.App.ClientConfigHash(),
|
wc.App.ClientConfigHash(),
|
||||||
wc.App.Srv().License() != nil))
|
wc.App.Channels().License() != nil))
|
||||||
msg.Add("connection_id", wc.connectionID.Load())
|
msg.Add("connection_id", wc.connectionID.Load())
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,14 +126,14 @@ func (c *Context) SessionRequired() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) CloudKeyRequired() {
|
func (c *Context) CloudKeyRequired() {
|
||||||
if license := c.App.Srv().License(); license == nil || !*license.Features.Cloud || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeCloudKey {
|
if license := c.App.Channels().License(); license == nil || !*license.Features.Cloud || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeCloudKey {
|
||||||
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "TokenRequired", http.StatusUnauthorized)
|
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "TokenRequired", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) RemoteClusterTokenRequired() {
|
func (c *Context) RemoteClusterTokenRequired() {
|
||||||
if license := c.App.Srv().License(); license == nil || !*license.Features.RemoteClusterService || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeRemoteclusterToken {
|
if license := c.App.Channels().License(); license == nil || !*license.Features.RemoteClusterService || c.AppContext.Session().Props[model.SessionPropType] != model.SessionTypeRemoteclusterToken {
|
||||||
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "TokenRequired", http.StatusUnauthorized)
|
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "TokenRequired", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ func (c *Context) RemoteClusterTokenRequired() {
|
|||||||
|
|
||||||
func (c *Context) MfaRequired() {
|
func (c *Context) MfaRequired() {
|
||||||
// Must be licensed for MFA and have it configured for enforcement
|
// Must be licensed for MFA and have it configured for enforcement
|
||||||
if license := c.App.Srv().License(); license == nil || !*license.Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication || !*c.App.Config().ServiceSettings.EnforceMultifactorAuthentication {
|
if license := c.App.Channels().License(); license == nil || !*license.Features.MFA || !*c.App.Config().ServiceSettings.EnableMultifactorAuthentication || !*c.App.Config().ServiceSettings.EnforceMultifactorAuthentication {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,20 +207,20 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
subpath, _ := utils.GetSubpathFromConfig(c.App.Config())
|
subpath, _ := utils.GetSubpathFromConfig(c.App.Config())
|
||||||
siteURLHeader := app.GetProtocol(r) + "://" + r.Host + subpath
|
siteURLHeader := app.GetProtocol(r) + "://" + r.Host + subpath
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
siteURLHeader = *c.App.Config().ServiceSettings.SiteURL + subpath
|
siteURLHeader = *c.App.Config().ServiceSettings.SiteURL + subpath
|
||||||
}
|
}
|
||||||
c.SetSiteURLHeader(siteURLHeader)
|
c.SetSiteURLHeader(siteURLHeader)
|
||||||
|
|
||||||
w.Header().Set(model.HeaderRequestId, c.AppContext.RequestId())
|
w.Header().Set(model.HeaderRequestId, c.AppContext.RequestId())
|
||||||
w.Header().Set(model.HeaderVersionId, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, c.App.ClientConfigHash(), c.App.Srv().License() != nil))
|
w.Header().Set(model.HeaderVersionId, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, c.App.ClientConfigHash(), c.App.Channels().License() != nil))
|
||||||
|
|
||||||
if *c.App.Config().ServiceSettings.TLSStrictTransport {
|
if *c.App.Config().ServiceSettings.TLSStrictTransport {
|
||||||
w.Header().Set("Strict-Transport-Security", fmt.Sprintf("max-age=%d", *c.App.Config().ServiceSettings.TLSStrictTransportMaxAge))
|
w.Header().Set("Strict-Transport-Security", fmt.Sprintf("max-age=%d", *c.App.Config().ServiceSettings.TLSStrictTransportMaxAge))
|
||||||
}
|
}
|
||||||
|
|
||||||
cloudCSP := ""
|
cloudCSP := ""
|
||||||
if c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud {
|
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
|
||||||
cloudCSP = " js.stripe.com/v3"
|
cloudCSP = " js.stripe.com/v3"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h.checkCSRFToken(c, r, token, tokenLocation, session)
|
h.checkCSRFToken(c, r, token, tokenLocation, session)
|
||||||
} else if token != "" && c.App.Srv().License() != nil && *c.App.Srv().License().Features.Cloud && tokenLocation == app.TokenLocationCloudHeader {
|
} else if token != "" && c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud && tokenLocation == app.TokenLocationCloudHeader {
|
||||||
// Check to see if this provided token matches our CWS Token
|
// Check to see if this provided token matches our CWS Token
|
||||||
session, err := c.App.GetCloudSession(token)
|
session, err := c.App.GetCloudSession(token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -281,7 +281,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
c.AppContext.SetSession(session)
|
c.AppContext.SetSession(session)
|
||||||
}
|
}
|
||||||
} else if token != "" && c.App.Srv().License() != nil && *c.App.Srv().License().Features.RemoteClusterService && tokenLocation == app.TokenLocationRemoteClusterHeader {
|
} else if token != "" && c.App.Channels().License() != nil && *c.App.Channels().License().Features.RemoteClusterService && tokenLocation == app.TokenLocationRemoteClusterHeader {
|
||||||
// Get the remote cluster
|
// Get the remote cluster
|
||||||
if remoteId := c.GetRemoteID(r); remoteId == "" {
|
if remoteId := c.GetRemoteID(r); remoteId == "" {
|
||||||
c.Logger.Warn("Missing remote cluster id") //
|
c.Logger.Warn("Missing remote cluster id") //
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user