// 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'); var UserStore = require('../stores/user_store.jsx'); var FindTeamDomain = React.createClass({ handleSubmit: function(e) { e.preventDefault(); var state = { } var domain = this.refs.domain.getDOMNode().value.trim(); if (!domain) { state.server_error = "A domain is required" this.setState(state); return; } state.server_error = ""; this.setState(state); client.findTeamByDomain(domain, function(data) { console.log(data); if (data) { window.location.href = window.location.protocol + "//" + domain + "." + utils.getDomainWithOutSub(); } else { this.state.server_error = "We couldn't find your " + strings.TeamPlural + "."; this.setState(this.state); } }.bind(this), function(err) { this.state.server_error = err.message; this.setState(this.state); }.bind(this) ); }, getInitialState: function() { return { }; }, render: function() { var server_error = this.state.server_error ? : null; return (
{ config.SiteName }
Enter your {strings.TeamPossessive} domain.

{ server_error }
Don't remember your {strings.TeamPossessive} domain? Find it here






{"Want to create your own " + strings.Team + "?"} Sign up now
); } }); module.exports = React.createClass({ handleSubmit: function(e) { e.preventDefault(); var state = { } var domain = this.refs.domain.getDOMNode().value.trim(); if (!domain) { state.server_error = "A domain is required" this.setState(state); return; } var email = this.refs.email.getDOMNode().value.trim(); if (!email) { state.server_error = "An email is required" this.setState(state); return; } var password = this.refs.password.getDOMNode().value.trim(); if (!password) { state.server_error = "A password is required" this.setState(state); return; } state.server_error = ""; this.setState(state); client.loginByEmail(domain, email, password, function(data) { UserStore.setLastDomain(domain); UserStore.setLastEmail(email); UserStore.setCurrentUser(data); var redirect = utils.getUrlParameter("redirect"); if (redirect) { window.location.href = decodeURI(redirect); } else { window.location.href = '/channels/town-square'; } }.bind(this), function(err) { if (err.message == "Login failed because email address has not been verified") { window.location.href = '/verify?domain=' + encodeURIComponent(domain) + '&email=' + encodeURIComponent(email); return; } state.server_error = err.message; this.valid = false; this.setState(state); }.bind(this) ); }, getInitialState: function() { return { }; }, render: function() { var server_error = this.state.server_error ? : null; var priorEmail = UserStore.getLastEmail() !== "undefined" ? UserStore.getLastEmail() : "" var emailParam = utils.getUrlParameter("email"); if (emailParam) { priorEmail = decodeURIComponent(emailParam); } var subDomainClass = "form-control hidden"; var subDomain = utils.getSubDomain(); if (utils.isTestDomain()) { subDomainClass = "form-control"; subDomain = UserStore.getLastDomain(); } else if (subDomain == "") { return (); } return (
{ subDomain }
{ utils.getDomainWithOutSub() }

{ server_error }
{"Find other " + strings.TeamPlural}
I forgot my password
{"Want to create your own " + strings.Team + "?"} Sign up now
); } });