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>
Этот коммит содержится в:
Agniva De Sarker
2022-03-10 09:00:29 +05:30
коммит произвёл GitHub
родитель 06c2aa70b0
Коммит 856f9b11af
19 изменённых файлов: 100 добавлений и 151 удалений

Просмотреть файл

@@ -135,7 +135,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
auditRec.AddMeta("token_type", token.Type)
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)
return
}
@@ -1389,7 +1389,7 @@ func updateUserRoles(c *Context, w http.ResponseWriter, r *http.Request) {
for _, roleName := range strings.Fields(newRoles) {
for _, id := range model.NewSystemRoleIDs {
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)
return
}
@@ -1830,7 +1830,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
ldapOnly := props["ldap_only"] == "true"
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)
return
}
@@ -1864,7 +1864,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
auditRec.AddMeta("user", user)
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)
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
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)
}
@@ -1913,7 +1913,7 @@ func login(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)
return
}
@@ -2683,7 +2683,7 @@ func demoteUserToGuest(c *Context, w http.ResponseWriter, r *http.Request) {
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)
return
}
@@ -2914,7 +2914,7 @@ func migrateAuthToLDAP(c *Context, w http.ResponseWriter, r *http.Request) {
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)
return
}
@@ -2973,7 +2973,7 @@ func migrateAuthToSaml(c *Context, w http.ResponseWriter, r *http.Request) {
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)
return
}