// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var utils = require('../utils/utils.jsx'); var client = require('../utils/client.jsx'); module.exports = React.createClass({ displayName: 'TeamSignupPasswordPage', propTypes: { state: React.PropTypes.object, updateParent: React.PropTypes.func }, submitBack: function(e) { e.preventDefault(); this.props.state.wizard = 'username'; this.props.updateParent(this.props.state); }, submitNext: function(e) { e.preventDefault(); var password = this.refs.password.getDOMNode().value.trim(); if (!password || password.length < 5) { this.setState({passwordError: 'Please enter at least 5 characters'}); return; } this.setState({passwordError: null, serverError: null}); $('#finish-button').button('loading'); var teamSignup = JSON.parse(JSON.stringify(this.props.state)); teamSignup.user.password = password; teamSignup.user.allow_marketing = true; delete teamSignup.wizard; client.createTeamFromSignup(teamSignup, function success() { client.track('signup', 'signup_team_08_complete'); var props = this.props; client.loginByEmail(teamSignup.team.name, teamSignup.team.email, teamSignup.user.password, function(data) { UserStore.setLastEmail(teamSignup.team.email); UserStore.setCurrentUser(teamSignup.user); if (this.props.hash > 0) { BrowserStore.setGlobalItem(this.props.hash, JSON.stringify({wizard: 'finished'})); } $('#sign-up-button').button('reset'); props.state.wizard = 'finished'; props.updateParent(props.state, true); window.location.href = '/'; }.bind(this), function(err) { if (err.message === 'Login failed because email address has not been verified') { window.location.href = '/verify_email?email=' + encodeURIComponent(teamSignup.team.email) + '&teamname=' + encodeURIComponent(teamSignup.team.name); } else { this.setState({serverError: err.message}); } }.bind(this) ); }.bind(this), function error(err) { this.setState({serverError: err.message}); $('#sign-up-button').button('reset'); }.bind(this) ); }, getInitialState: function() { return {}; }, render: function() { client.track('signup', 'signup_team_07_password'); var passwordError = null; var passwordDivStyle = 'form-group'; if (this.state.passwordError) { passwordError =
; passwordDivStyle = ' has-error'; } var serverError = null; if (this.state.serverError) { serverError =
; } return (

Your password

Select a password that you'll use to login with your email address:
Email
{this.props.state.team.email}
Choose your password
Passwords must contain 5 to 50 characters. Your password will be strongest if it contains a mix of symbols, numbers, and upper and lowercase characters.
{passwordError} {serverError}

By proceeding to create your account and use {config.SiteName}, you agree to our Terms of Service and Privacy Policy. If you do not agree, you cannot use {config.SiteName}.

Back to previous step
); } });