diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-07-29 14:58:37 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-07-29 14:58:37 -0400 |
commit | 3f8dda6f5ad676c976fd5ae575a6790fdb505449 (patch) | |
tree | 015a739989103ce38481176fd5d55f5f703789cb /webapp/components/user_settings | |
parent | 748fdef1fbded624a786533e8f065b91a047b91c (diff) | |
download | chat-3f8dda6f5ad676c976fd5ae575a6790fdb505449.tar.gz chat-3f8dda6f5ad676c976fd5ae575a6790fdb505449.tar.bz2 chat-3f8dda6f5ad676c976fd5ae575a6790fdb505449.zip |
PLT-3633 EE: Add Google and Office365 SSO through OAuth2 (#3660)
* EE: Add Google and Office365 SSO through OAuth2
* Add localization strings
* Text tweaks for PLT-3633
* Added sign-up button for Office 365
* Updated some error messages and a bit of licensing
* Updated sign-in method section in user settings to include Google and Office365
* Added more localization strings
Diffstat (limited to 'webapp/components/user_settings')
-rw-r--r-- | webapp/components/user_settings/user_settings_general.jsx | 56 | ||||
-rw-r--r-- | webapp/components/user_settings/user_settings_security.jsx | 192 |
2 files changed, 167 insertions, 81 deletions
diff --git a/webapp/components/user_settings/user_settings_general.jsx b/webapp/components/user_settings/user_settings_general.jsx index 8dce4deed..d1c195c7e 100644 --- a/webapp/components/user_settings/user_settings_general.jsx +++ b/webapp/components/user_settings/user_settings_general.jsx @@ -419,6 +419,42 @@ class UserSettingsGeneralTab extends React.Component { {helpText} </div> ); + } else if (this.props.user.auth_service === Constants.GOOGLE_SERVICE) { + inputs.push( + <div + key='oauthEmailInfo' + className='form-group' + > + <div className='setting-list__hint'> + <FormattedMessage + id='user.settings.general.emailGoogleCantUpdate' + defaultMessage='Login occurs through Google Apps. Email cannot be updated. Email address used for notifications is {email}.' + values={{ + email: this.state.email + }} + /> + </div> + {helpText} + </div> + ); + } else if (this.props.user.auth_service === Constants.OFFICE365_SERVICE) { + inputs.push( + <div + key='oauthEmailInfo' + className='form-group' + > + <div className='setting-list__hint'> + <FormattedMessage + id='user.settings.general.emailOffice365CantUpdate' + defaultMessage='Login occurs through Office 365. Email cannot be updated. Email address used for notifications is {email}.' + values={{ + email: this.state.email + }} + /> + </div> + {helpText} + </div> + ); } else if (this.props.user.auth_service === Constants.LDAP_SERVICE) { inputs.push( <div @@ -511,6 +547,26 @@ class UserSettingsGeneralTab extends React.Component { }} /> ); + } else if (this.props.user.auth_service === Constants.GOOGLE_SERVICE) { + describe = ( + <FormattedMessage + id='user.settings.general.loginGoogle' + defaultMessage='Login done through Google Apps ({email})' + values={{ + email: this.state.email + }} + /> + ); + } else if (this.props.user.auth_service === Constants.OFFICE365_SERVICE) { + describe = ( + <FormattedMessage + id='user.settings.general.loginOffice365' + defaultMessage='Login done through Office 365 ({email})' + values={{ + email: this.state.email + }} + /> + ); } else if (this.props.user.auth_service === Constants.LDAP_SERVICE) { describe = ( <FormattedMessage diff --git a/webapp/components/user_settings/user_settings_security.jsx b/webapp/components/user_settings/user_settings_security.jsx index a4f02a614..428c88e25 100644 --- a/webapp/components/user_settings/user_settings_security.jsx +++ b/webapp/components/user_settings/user_settings_security.jsx @@ -1,7 +1,6 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import $ from 'jquery'; import SettingItemMin from '../setting_item_min.jsx'; import SettingItemMax from '../setting_item_max.jsx'; import AccessHistoryModal from '../access_history_modal.jsx'; @@ -9,13 +8,14 @@ import ActivityLogModal from '../activity_log_modal.jsx'; import ToggleModalButton from '../toggle_modal_button.jsx'; import PreferenceStore from 'stores/preference_store.jsx'; -import TeamStore from 'stores/team_store.jsx'; import Client from 'client/web_client.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; import Constants from 'utils/constants.jsx'; +import $ from 'jquery'; +import React from 'react'; import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage, FormattedTime, FormattedDate} from 'react-intl'; import {Link} from 'react-router/es6'; @@ -42,8 +42,6 @@ const holders = defineMessages({ } }); -import React from 'react'; - class SecurityTab extends React.Component { constructor(props) { super(props); @@ -543,10 +541,99 @@ class SecurityTab extends React.Component { const user = this.props.user; if (this.props.activeSection === 'signin') { - const teamName = TeamStore.getCurrent().name; - let emailOption; - if (global.window.mm_config.EnableSignUpWithEmail === 'true' && user.auth_service !== '') { + let gitlabOption; + let googleOption; + let office365Option; + let ldapOption; + let samlOption; + + if (user.auth_service === '') { + if (global.window.mm_config.EnableSignUpWithGitLab === 'true') { + gitlabOption = ( + <div className='padding-bottom x2'> + <Link + className='btn btn-primary' + to={'/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.GITLAB_SERVICE} + > + <FormattedMessage + id='user.settings.security.switchGitlab' + defaultMessage='Switch to using GitLab SSO' + /> + </Link> + <br/> + </div> + ); + } + + if (global.window.mm_config.EnableSignUpWithGoogle === 'true') { + googleOption = ( + <div className='padding-bottom x2'> + <Link + className='btn btn-primary' + to={'/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.GOOGLE_SERVICE} + > + <FormattedMessage + id='user.settings.security.switchGoogle' + defaultMessage='Switch to using Google SSO' + /> + </Link> + <br/> + </div> + ); + } + + if (global.window.mm_config.EnableSignUpWithOffice365 === 'true') { + office365Option = ( + <div className='padding-bottom x2'> + <Link + className='btn btn-primary' + to={'/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.OFFICE365_SERVICE} + > + <FormattedMessage + id='user.settings.security.switchOffice365' + defaultMessage='Switch to using Office 365 SSO' + /> + </Link> + <br/> + </div> + ); + } + + if (global.window.mm_config.EnableLdap === 'true') { + ldapOption = ( + <div className='padding-bottom x2'> + <Link + className='btn btn-primary' + to={'/claim/email_to_ldap?email=' + encodeURIComponent(user.email)} + > + <FormattedMessage + id='user.settings.security.switchLdap' + defaultMessage='Switch to using LDAP' + /> + </Link> + <br/> + </div> + ); + } + + if (global.window.mm_config.EnableSaml === 'true') { + samlOption = ( + <div className='padding-bottom x2'> + <Link + className='btn btn-primary' + to={'/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.SAML_SERVICE} + > + <FormattedMessage + id='user.settings.security.switchSaml' + defaultMessage='Switch to using SAML SSO' + /> + </Link> + <br/> + </div> + ); + } + } else if (global.window.mm_config.EnableSignUpWithEmail === 'true') { let link; if (user.auth_service === Constants.LDAP_SERVICE) { link = '/claim/ldap_to_email?email=' + encodeURIComponent(user.email); @@ -570,86 +657,15 @@ class SecurityTab extends React.Component { ); } - let gitlabOption; - if (global.window.mm_config.EnableSignUpWithGitLab === 'true' && user.auth_service === '') { - gitlabOption = ( - <div className='padding-bottom x2'> - <Link - className='btn btn-primary' - to={'/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.GITLAB_SERVICE} - > - <FormattedMessage - id='user.settings.security.switchGitlab' - defaultMessage='Switch to using GitLab SSO' - /> - </Link> - <br/> - </div> - ); - } - - let googleOption; - if (global.window.mm_config.EnableSignUpWithGoogle === 'true' && user.auth_service === '') { - googleOption = ( - <div className='padding-bottom x2'> - <Link - className='btn btn-primary' - to={'/' + teamName + '/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.GOOGLE_SERVICE} - > - <FormattedMessage - id='user.settings.security.switchGoogle' - defaultMessage='Switch to using Google SSO' - /> - </Link> - <br/> - </div> - ); - } - - let ldapOption; - if (global.window.mm_config.EnableLdap === 'true' && user.auth_service === '') { - ldapOption = ( - <div className='padding-bottom x2'> - <Link - className='btn btn-primary' - to={'/claim/email_to_ldap?email=' + encodeURIComponent(user.email)} - > - <FormattedMessage - id='user.settings.security.switchLdap' - defaultMessage='Switch to using LDAP' - /> - </Link> - <br/> - </div> - ); - } - - let samlOption; - if (global.window.mm_config.EnableSaml === 'true' && user.auth_service === '') { - samlOption = ( - <div className='padding-bottom x2'> - <Link - className='btn btn-primary' - to={'/claim/email_to_oauth?email=' + encodeURIComponent(user.email) + '&old_type=' + user.auth_service + '&new_type=' + Constants.SAML_SERVICE} - > - <FormattedMessage - id='user.settings.security.switchSaml' - defaultMessage='Switch to using SAML SSO' - /> - </Link> - <br/> - </div> - ); - } - const inputs = []; inputs.push( <div key='userSignInOption'> {emailOption} {gitlabOption} + {googleOption} + {office365Option} {ldapOption} {samlOption} - {googleOption} </div> ); @@ -693,7 +709,21 @@ class SecurityTab extends React.Component { describe = ( <FormattedMessage id='user.settings.security.gitlab' - defaultMessage='GitLab SSO' + defaultMessage='GitLab' + /> + ); + } else if (this.props.user.auth_service === Constants.GOOGLE_SERVICE) { + describe = ( + <FormattedMessage + id='user.settings.security.google' + defaultMessage='Google' + /> + ); + } else if (this.props.user.auth_service === Constants.OFFICE365_SERVICE) { + describe = ( + <FormattedMessage + id='user.settings.security.office365' + defaultMessage='Office 365' /> ); } else if (this.props.user.auth_service === Constants.LDAP_SERVICE) { |