From 777012eee42186316bc68b0ea1c8232601962bc4 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 7 Mar 2016 14:59:15 -0800 Subject: PLT-1830 Adding ability to create team with ldap --- web/react/components/signup_team.jsx | 14 ++ web/react/components/team_signup_choose_auth.jsx | 24 +++ web/react/components/team_signup_with_ldap.jsx | 234 +++++++++++++++++++++++ web/react/utils/client.jsx | 15 ++ web/sass-files/sass/partials/_signup.scss | 9 + web/static/i18n/en.json | 6 + 6 files changed, 302 insertions(+) create mode 100644 web/react/components/team_signup_with_ldap.jsx (limited to 'web') diff --git a/web/react/components/signup_team.jsx b/web/react/components/signup_team.jsx index 5e8ae117d..26c46dad0 100644 --- a/web/react/components/signup_team.jsx +++ b/web/react/components/signup_team.jsx @@ -4,6 +4,7 @@ import ChoosePage from './team_signup_choose_auth.jsx'; import EmailSignUpPage from './team_signup_with_email.jsx'; import SSOSignupPage from './team_signup_with_sso.jsx'; +import LdapSignUpPage from './team_signup_with_ldap.jsx'; import Constants from '../utils/constants.jsx'; import {FormattedMessage} from 'mm-intl'; @@ -24,12 +25,18 @@ export default class TeamSignUp extends React.Component { count = count + 1; } + if (global.window.mm_config.EnableLdap === 'true') { + count = count + 1; + } + if (count > 1) { this.state = {page: 'choose'}; } else if (global.window.mm_config.EnableSignUpWithEmail === 'true') { this.state = {page: 'email'}; } else if (global.window.mm_config.EnableSignUpWithGitLab === 'true') { this.state = {page: 'gitlab'}; + } else if (global.window.mm_config.EnableLdap === 'true') { + this.state = {page: 'ldap'}; } else { this.state = {page: 'none'}; } @@ -133,6 +140,13 @@ export default class TeamSignUp extends React.Component { ); + } else if (this.state.page === 'ldap') { + return ( +
+ {teamListing} + +
+ ); } else if (this.state.page === 'gitlab') { return (
diff --git a/web/react/components/team_signup_choose_auth.jsx b/web/react/components/team_signup_choose_auth.jsx index 8c98c5538..5db83fe7d 100644 --- a/web/react/components/team_signup_choose_auth.jsx +++ b/web/react/components/team_signup_choose_auth.jsx @@ -58,6 +58,30 @@ export default class ChooseAuthPage extends React.Component { ); } + if (global.window.mm_config.EnableLdap === 'true') { + buttons.push( + { + e.preventDefault(); + this.props.updatePage('ldap'); + } + } + > + + + + + + ); + } + if (global.window.mm_config.EnableSignUpWithEmail === 'true') { buttons.push( { + Client.track('signup', 'signup_team_ldap_complete'); + + Client.loginByLdap(teamSignup.team.name, id, password, + () => { + window.location.href = '/' + teamSignup.team.name + '/channels/town-square'; + }, + (err) => { + $('#ldap-button').button('reset'); + this.setState({serverError: err.message}); + } + ); + }, + (err) => { + $('#ldap-button').button('reset'); + this.setState({serverError: err.message}); + } + ); + } + + valueChange() { + this.setState({ + name: ReactDOM.findDOMNode(this.refs.teamname).value.trim(), + id: ReactDOM.findDOMNode(this.refs.id).value.trim(), + password: ReactDOM.findDOMNode(this.refs.password).value.trim() + }); + } + + render() { + const {formatMessage} = this.props.intl; + var nameError = null; + var nameDivClass = 'form-group'; + if (this.state.nameError) { + nameError = ; + nameDivClass += ' has-error'; + } + + var serverError = null; + if (this.state.serverError) { + serverError =
; + } + + var disabled = false; + if (this.state.name.length <= 2) { + disabled = true; + } + + if (this.state.id.length <= 1) { + disabled = true; + } + + if (this.state.password.length <= 1) { + disabled = true; + } + + return ( +
+
+ + {nameError} +
+
+ +
+
+ +
+
+ + + + + + + {serverError} +
+
+ + + +
+
+ ); + } +} + +LdapSignUpPage.propTypes = { + intl: intlShape.isRequired +}; + +export default injectIntl(LdapSignUpPage); \ No newline at end of file diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 1a002bc8c..76d42137a 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -87,6 +87,21 @@ export function createTeamFromSignup(teamSignup, success, error) { }); } +export function createTeamWithLdap(teamSignup, success, error) { + $.ajax({ + url: '/api/v1/teams/create_with_ldap', + dataType: 'json', + contentType: 'application/json', + type: 'POST', + data: JSON.stringify(teamSignup), + success, + error: function onError(xhr, status, err) { + var e = handleError('createTeamFromSignup', xhr, status, err); + error(e); + } + }); +} + export function createTeamWithSSO(team, service, success, error) { $.ajax({ url: '/api/v1/teams/create_with_sso/' + service, diff --git a/web/sass-files/sass/partials/_signup.scss b/web/sass-files/sass/partials/_signup.scss index 38ae14d7d..6d396d21c 100644 --- a/web/sass-files/sass/partials/_signup.scss +++ b/web/sass-files/sass/partials/_signup.scss @@ -214,6 +214,15 @@ background-image: url("../images/googleLogo.png"); } } + &.ldap { + background: #dd4b39; + &:hover { + background: darken(#dd4b39, 10%); + } + span { + vertical-align: middle; + } + } &.email { background: #2389D7; &:hover { diff --git a/web/static/i18n/en.json b/web/static/i18n/en.json index 114b6bdb5..96672eba6 100644 --- a/web/static/i18n/en.json +++ b/web/static/i18n/en.json @@ -593,6 +593,7 @@ "choose_auth_page.find": "Find my teams", "choose_auth_page.gitlabCreate": "Create new team with GitLab Account", "choose_auth_page.googleCreate": "Create new team with Google Apps Account", + "choose_auth_page.ldapCreate": "Create new team with LDAP Account", "choose_auth_page.noSignup": "No sign-up methods configured, please contact your system administrator.", "claim.account.noEmail": "No email specified", "claim.email_to_sso.enterPwd": "Enter the password for your {team} {site} account", @@ -964,6 +965,11 @@ "sso_signup.length_error": "Name must be 3 or more characters up to a maximum of 15", "sso_signup.teamName": "Enter name of new team", "sso_signup.team_error": "Please enter a team name", + "ldap_signup.find": "Find my teams", + "ldap_signup.ldap": "Create team with LDAP Account", + "ldap_signup.length_error": "Name must be 3 or more characters up to a maximum of 15", + "ldap_signup.teamName": "Enter name of new team", + "ldap_signup.team_error": "Please enter a team name", "suggestion.mention.all": "Notifies everyone in the team", "suggestion.mention.channel": "Notifies everyone in the channel", "suggestion.search.private": "Public Groups", -- cgit v1.2.3-1-g7c22