Add Office 365 login support (#2628)

This commit is contained in:
Elias Nahum 2019-03-11 06:58:59 -03:00 committed by Sudheer
parent 4e1479d449
commit a941ce5fff
6 changed files with 47 additions and 1 deletions

View file

@ -58,6 +58,7 @@ const ViewTypes = keyMirror({
REMOVE_LAST_CHANNEL_FOR_TEAM: null,
GITLAB: null,
OFFICE365: null,
SAML: null,
SET_INITIAL_POST_VISIBILITY: null,

View file

@ -188,6 +188,41 @@ class LoginOptions extends PureComponent {
return null;
};
renderO365Option = () => {
const {config, license} = this.props;
const forceHideFromLocal = LocalConfig.HideO365LoginExperimental;
const o365Enabled = config.EnableSignUpWithOffice365 === 'true' && license.IsLicensed === 'true' && license.Office365OAuth === 'true';
if (!forceHideFromLocal && o365Enabled) {
const backgroundColor = config.EmailLoginButtonColor || '#2389d7';
const additionalStyle = {
backgroundColor,
};
if (config.EmailLoginButtonBorderColor) {
additionalStyle.borderColor = config.EmailLoginButtonBorderColor;
}
const textColor = config.EmailLoginButtonTextColor || 'white';
return (
<Button
key='o365'
onPress={preventDoubleTap(() => this.goToSSO(ViewTypes.OFFICE365))}
containerStyle={[GlobalStyles.signupButton, additionalStyle]}
>
<FormattedText
id='signup.office365'
defaultMessage='Office 365'
style={[GlobalStyles.signupButtonText, {color: textColor}]}
/>
</Button>
);
}
return null;
};
renderSamlOption = () => {
const {config, license} = this.props;
const forceHideFromLocal = LocalConfig.HideSAMLLoginExperimental;
@ -255,6 +290,7 @@ class LoginOptions extends PureComponent {
{this.renderLdapOption()}
{this.renderGitlabOption()}
{this.renderSamlOption()}
{this.renderO365Option()}
</ScrollView>
);
}

View file

@ -205,9 +205,10 @@ export default class SelectServer extends PureComponent {
const {config, license} = props;
const samlEnabled = config.EnableSaml === 'true' && license.IsLicensed === 'true' && license.SAML === 'true';
const gitlabEnabled = config.EnableSignUpWithGitLab === 'true';
const o365Enabled = config.EnableSignUpWithOffice365 === 'true' && license.IsLicensed === 'true' && license.Office365OAuth === 'true';
let options = 0;
if (samlEnabled || gitlabEnabled) {
if (samlEnabled || gitlabEnabled || o365Enabled) {
options += 1;
}

View file

@ -90,6 +90,10 @@ class SSO extends PureComponent {
this.loginUrl = `${props.serverUrl}/login/sso/saml?action=mobile`;
this.completedUrl = '/login/sso/saml';
break;
case ViewTypes.OFFICE365:
this.loginUrl = `${props.serverUrl}/oauth/office365/mobile_login`;
this.completedUrl = '/signup/office365/complete';
break;
}
}
@ -234,6 +238,8 @@ class SSO extends PureComponent {
onLoadEnd={this.onLoadEnd}
onMessage={messagingEnabled ? this.onMessage : null}
useWebKit={true}
useSharedProcessPool={true}
cacheEnabled={true}
/>
);
}

View file

@ -17,6 +17,7 @@
"HideGitLabLoginExperimental": false,
"HideLDAPLoginExperimental": false,
"HideSAMLLoginExperimental": false,
"HideO365LoginExperimental": false,
"SentryEnabled": false,
"SentryDsnIos": "",

View file

@ -498,6 +498,7 @@
"sidebar.unreadSection": "UNREADS",
"sidebar.unreads": "More unreads",
"signup.email": "Email and Password",
"signup.office365": "Office 365",
"status_dropdown.set_away": "Away",
"status_dropdown.set_dnd": "Do Not Disturb",
"status_dropdown.set_offline": "Offline",