summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-08-30 23:05:23 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-08-30 22:05:23 -0400
commitdb660bdf9cbea09197d8292a8ec8efda8ac41f38 (patch)
tree00845d6b588c0b149dc56a90b1c7ef9abfc9b9ff
parent1326ab66a141e73f1ef7d9d39bb86596f56179e0 (diff)
downloadchat-db660bdf9cbea09197d8292a8ec8efda8ac41f38.tar.gz
chat-db660bdf9cbea09197d8292a8ec8efda8ac41f38.tar.bz2
chat-db660bdf9cbea09197d8292a8ec8efda8ac41f38.zip
PLT-4007 Fix OAuth: Javascript error when team admin accesses the OAuth 2.0 menu (#3887)
-rw-r--r--webapp/components/backstage/components/backstage_sidebar.jsx5
-rw-r--r--webapp/components/integrations/components/integrations.jsx8
-rw-r--r--webapp/components/navbar_dropdown.jsx2
3 files changed, 10 insertions, 5 deletions
diff --git a/webapp/components/backstage/components/backstage_sidebar.jsx b/webapp/components/backstage/components/backstage_sidebar.jsx
index 554e3043e..557c6d804 100644
--- a/webapp/components/backstage/components/backstage_sidebar.jsx
+++ b/webapp/components/backstage/components/backstage_sidebar.jsx
@@ -40,6 +40,7 @@ export default class BackstageSidebar extends React.Component {
renderIntegrations() {
const config = window.mm_config;
+ const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
if (config.EnableIncomingWebhooks !== 'true' &&
config.EnableOutgoingWebhooks !== 'true' &&
config.EnableCommands !== 'true' &&
@@ -48,7 +49,7 @@ export default class BackstageSidebar extends React.Component {
}
if (config.EnableOnlyAdminIntegrations !== 'false' &&
- !Utils.isSystemAdmin(this.props.user.roles) &&
+ !isSystemAdmin &&
!TeamStore.isTeamAdmin(this.props.user.id, this.props.team.id)) {
return null;
}
@@ -99,7 +100,7 @@ export default class BackstageSidebar extends React.Component {
}
let oauthApps = null;
- if (config.EnableOAuthServiceProvider === 'true') {
+ if (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
oauthApps = (
<BackstageSection
name='oauth2-apps'
diff --git a/webapp/components/integrations/components/integrations.jsx b/webapp/components/integrations/components/integrations.jsx
index b1c103a7e..e0cc4da22 100644
--- a/webapp/components/integrations/components/integrations.jsx
+++ b/webapp/components/integrations/components/integrations.jsx
@@ -11,16 +11,20 @@ import OutgoingWebhookIcon from 'images/outgoing_webhook.jpg';
import SlashCommandIcon from 'images/slash_command_icon.jpg';
import OAuthIcon from 'images/oauth_icon.png';
+import * as Utils from 'utils/utils.jsx';
+
export default class Integrations extends React.Component {
static get propTypes() {
return {
- team: React.propTypes.object.isRequired
+ team: React.propTypes.object.isRequired,
+ user: React.PropTypes.object.isRequired
};
}
render() {
const options = [];
const config = window.mm_config;
+ const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
if (config.EnableIncomingWebhooks === 'true') {
options.push(
@@ -88,7 +92,7 @@ export default class Integrations extends React.Component {
);
}
- if (config.EnableOAuthServiceProvider === 'true') {
+ if (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
options.push(
<IntegrationOption
key='oauth2Apps'
diff --git a/webapp/components/navbar_dropdown.jsx b/webapp/components/navbar_dropdown.jsx
index 39bd6b159..719ec74d9 100644
--- a/webapp/components/navbar_dropdown.jsx
+++ b/webapp/components/navbar_dropdown.jsx
@@ -205,7 +205,7 @@ export default class NavbarDropdown extends React.Component {
config.EnableIncomingWebhooks === 'true' ||
config.EnableOutgoingWebhooks === 'true' ||
config.EnableCommands === 'true' ||
- config.EnableOAuthServiceProvider === 'true';
+ (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true'));
if (integrationsEnabled && (isAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
integrationsLink = (
<li>