diff --git a/api/oauth.go b/api/oauth.go
index 18a9979f6a..233ae08796 100644
--- a/api/oauth.go
+++ b/api/oauth.go
@@ -102,6 +102,7 @@ func getOAuthApps(c *Context, w http.ResponseWriter, r *http.Request) {
if HasPermissionToContext(c, model.PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH) {
ochan = Srv.Store.OAuth().GetApps()
} else {
+ c.Err = nil
ochan = Srv.Store.OAuth().GetAppByUser(c.Session.UserId)
}
diff --git a/api/oauth_test.go b/api/oauth_test.go
index da069aefe6..1dcdd55e3c 100644
--- a/api/oauth_test.go
+++ b/api/oauth_test.go
@@ -156,8 +156,8 @@ func TestGetOAuthAppsByUser(t *testing.T) {
utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
- if _, err := Client.GetOAuthAppsByUser(); err == nil {
- t.Fatal("Should have failed. only admin is permitted")
+ if _, err := Client.GetOAuthAppsByUser(); err != nil {
+ t.Fatal("Should have passed.")
}
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
diff --git a/model/authorization.go b/model/authorization.go
index a4d8bed866..75aebf55cd 100644
--- a/model/authorization.go
+++ b/model/authorization.go
@@ -311,6 +311,7 @@ func InitalizeRoles() {
[]string{
PERMISSION_CREATE_DIRECT_CHANNEL.Id,
PERMISSION_PERMANENT_DELETE_USER.Id,
+ PERMISSION_MANAGE_OAUTH.Id,
},
}
BuiltInRoles[ROLE_SYSTEM_USER.Id] = ROLE_SYSTEM_USER
diff --git a/webapp/components/integrations/components/installed_oauth_apps.jsx b/webapp/components/integrations/components/installed_oauth_apps.jsx
index 39ef347e20..322c95511a 100644
--- a/webapp/components/integrations/components/installed_oauth_apps.jsx
+++ b/webapp/components/integrations/components/installed_oauth_apps.jsx
@@ -71,6 +71,17 @@ export default class InstalledOAuthApps extends React.Component {
);
});
+ const isSystemAdmin = UserStore.isSystemAdminForCurrentUser();
+ const config = global.mm_config;
+ const integrationsEnabled = (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true'));
+ let props;
+ if (integrationsEnabled) {
+ props = {
+ addLink: '/' + this.props.team.name + '/integrations/oauth2-apps/add',
+ addText: localizeMessage('installed_oauth_apps.add', 'Add OAuth 2.0 Application')
+ };
+ }
+
return (
}
- addText={
-
- }
- addLink={'/' + this.props.team.name + '/integrations/oauth2-apps/add'}
emptyText={
{oauthApps}