summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-01-04 14:11:48 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2017-01-04 14:11:47 -0500
commit635628cf30460a75d3a870394ad66db91f3bea9f (patch)
tree17d40987fab0876c6dc95acec7f82b4f3eb36c01
parentb3f2ab654e95325b556e0c93b41ea6e15e45fffe (diff)
downloadchat-635628cf30460a75d3a870394ad66db91f3bea9f.tar.gz
chat-635628cf30460a75d3a870394ad66db91f3bea9f.tar.bz2
chat-635628cf30460a75d3a870394ad66db91f3bea9f.zip
Removing old signup team API (#4950)
-rw-r--r--api/team.go52
-rw-r--r--api/team_test.go11
-rw-r--r--api/user.go2
-rw-r--r--model/client.go16
-rw-r--r--model/team_signup.go40
-rw-r--r--model/team_signup_test.go20
-rw-r--r--webapp/client/client.jsx12
-rw-r--r--webapp/components/signup_team_complete/components/signup_team_complete.jsx81
-rw-r--r--webapp/tests/client_team.test.jsx16
9 files changed, 1 insertions, 249 deletions
diff --git a/api/team.go b/api/team.go
index be64403a2..c17bf87af 100644
--- a/api/team.go
+++ b/api/team.go
@@ -25,7 +25,6 @@ func InitTeam() {
l4g.Debug(utils.T("api.team.init.debug"))
BaseRoutes.Teams.Handle("/create", ApiAppHandler(createTeam)).Methods("POST")
- BaseRoutes.Teams.Handle("/signup", ApiAppHandler(signupTeam)).Methods("POST")
BaseRoutes.Teams.Handle("/all", ApiAppHandler(getAll)).Methods("GET")
BaseRoutes.Teams.Handle("/all_team_listings", ApiUserRequired(GetAllTeamListings)).Methods("GET")
BaseRoutes.Teams.Handle("/get_invite_info", ApiAppHandler(getInviteInfo)).Methods("POST")
@@ -52,57 +51,6 @@ func InitTeam() {
BaseRoutes.Teams.Handle("/add_user_to_team_from_invite", ApiUserRequired(addUserToTeamFromInvite)).Methods("POST")
}
-func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) {
- if !utils.Cfg.EmailSettings.EnableSignUpWithEmail {
- c.Err = model.NewLocAppError("signupTeam", "api.team.signup_team.email_disabled.app_error", nil, "")
- c.Err.StatusCode = http.StatusNotImplemented
- return
- }
-
- m := model.MapFromJson(r.Body)
- email := strings.ToLower(strings.TrimSpace(m["email"]))
-
- if len(email) == 0 {
- c.SetInvalidParam("signupTeam", "email")
- return
- }
-
- if !isTeamCreationAllowed(c, email) {
- return
- }
-
- subject := c.T("api.templates.signup_team_subject",
- map[string]interface{}{"SiteName": utils.ClientCfg["SiteName"]})
-
- bodyPage := utils.NewHTMLTemplate("signup_team_body", c.Locale)
- bodyPage.Props["SiteURL"] = c.GetSiteURL()
- bodyPage.Props["Title"] = c.T("api.templates.signup_team_body.title")
- bodyPage.Props["Button"] = c.T("api.templates.signup_team_body.button")
- bodyPage.Html["Info"] = template.HTML(c.T("api.templates.signup_team_body.info",
- map[string]interface{}{"SiteName": utils.ClientCfg["SiteName"]}))
-
- props := make(map[string]string)
- props["email"] = email
- props["time"] = fmt.Sprintf("%v", model.GetMillis())
-
- data := model.MapToJson(props)
- hash := model.HashPassword(fmt.Sprintf("%v:%v", data, utils.Cfg.EmailSettings.InviteSalt))
-
- bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_team_complete/?d=%s&h=%s", c.GetSiteURL(), url.QueryEscape(data), url.QueryEscape(hash))
-
- if err := utils.SendMail(email, subject, bodyPage.Render()); err != nil {
- c.Err = err
- return
- }
-
- if !utils.Cfg.EmailSettings.RequireEmailVerification {
- m["follow_link"] = fmt.Sprintf("/signup_team_complete/?d=%s&h=%s", url.QueryEscape(data), url.QueryEscape(hash))
- }
-
- w.Header().Set("Access-Control-Allow-Origin", " *")
- w.Write([]byte(model.MapToJson(m)))
-}
-
func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
team := model.TeamFromJson(r.Body)
diff --git a/api/team_test.go b/api/team_test.go
index 174bbda76..7403afd8a 100644
--- a/api/team_test.go
+++ b/api/team_test.go
@@ -11,17 +11,6 @@ import (
"github.com/mattermost/platform/utils"
)
-func TestSignupTeam(t *testing.T) {
- th := Setup().InitBasic()
- th.BasicClient.Logout()
- Client := th.BasicClient
-
- _, err := Client.SignupTeam("test@nowhere.com", "name")
- if err != nil {
- t.Fatal(err)
- }
-}
-
func TestCreateTeam(t *testing.T) {
th := Setup().InitBasic()
th.BasicClient.Logout()
diff --git a/api/user.go b/api/user.go
index 4e853f697..760f4faea 100644
--- a/api/user.go
+++ b/api/user.go
@@ -89,7 +89,7 @@ func InitUser() {
func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
if !utils.Cfg.EmailSettings.EnableSignUpWithEmail || !utils.Cfg.TeamSettings.EnableUserCreation {
- c.Err = model.NewLocAppError("signupTeam", "api.user.create_user.signup_email_disabled.app_error", nil, "")
+ c.Err = model.NewLocAppError("createUser", "api.user.create_user.signup_email_disabled.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented
return
}
diff --git a/model/client.go b/model/client.go
index 0c8bdcc5b..540bc747f 100644
--- a/model/client.go
+++ b/model/client.go
@@ -299,22 +299,6 @@ func (c *Client) GetPing() (map[string]string, *AppError) {
// Team Routes Section
-// SignupTeam sends an email with a team sign-up link to the provided address if email
-// verification is enabled, otherwise it returns a map with a "follow_link" entry
-// containing the team sign-up link.
-func (c *Client) SignupTeam(email string, displayName string) (*Result, *AppError) {
- m := make(map[string]string)
- m["email"] = email
- m["display_name"] = displayName
- if r, err := c.DoApiPost("/teams/signup", MapToJson(m)); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
- }
-}
-
// CreateTeam creates a team based on the provided Team struct. On success it returns
// the Team struct with the Id, CreateAt and other server-decided fields populated.
func (c *Client) CreateTeam(team *Team) (*Result, *AppError) {
diff --git a/model/team_signup.go b/model/team_signup.go
deleted file mode 100644
index e36420449..000000000
--- a/model/team_signup.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "io"
-)
-
-type TeamSignup struct {
- Team Team `json:"team"`
- User User `json:"user"`
- Invites []string `json:"invites"`
- Data string `json:"data"`
- Hash string `json:"hash"`
-}
-
-func TeamSignupFromJson(data io.Reader) *TeamSignup {
- decoder := json.NewDecoder(data)
- var o TeamSignup
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- fmt.Println(err)
-
- return nil
- }
-}
-
-func (o *TeamSignup) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
diff --git a/model/team_signup_test.go b/model/team_signup_test.go
deleted file mode 100644
index a830842aa..000000000
--- a/model/team_signup_test.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "strings"
- "testing"
-)
-
-func TestTeamSignupJson(t *testing.T) {
- team := Team{Id: NewId(), DisplayName: NewId()}
- o := TeamSignup{Team: team, Data: "data"}
- json := o.ToJson()
- ro := TeamSignupFromJson(strings.NewReader(json))
-
- if o.Team.Id != ro.Team.Id {
- t.Fatal("Ids do not match")
- }
-}
diff --git a/webapp/client/client.jsx b/webapp/client/client.jsx
index e5fe25fcd..ba42d7ae8 100644
--- a/webapp/client/client.jsx
+++ b/webapp/client/client.jsx
@@ -446,18 +446,6 @@ export default class Client {
end(this.handleResponse.bind(this, 'exportTeam', success, error));
}
- signupTeam(email, success, error) {
- request.
- post(`${this.getTeamsRoute()}/signup`).
- set(this.defaultHeaders).
- type('application/json').
- accept('application/json').
- send({email}).
- end(this.handleResponse.bind(this, 'signupTeam', success, error));
-
- this.track('api', 'api_teams_signup');
- }
-
adminResetMfa(userId, success, error) {
const data = {};
data.user_id = userId;
diff --git a/webapp/components/signup_team_complete/components/signup_team_complete.jsx b/webapp/components/signup_team_complete/components/signup_team_complete.jsx
deleted file mode 100644
index 78c591375..000000000
--- a/webapp/components/signup_team_complete/components/signup_team_complete.jsx
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-import BrowserStore from 'stores/browser_store.jsx';
-
-import {FormattedMessage} from 'react-intl';
-
-import React from 'react';
-import {Link, browserHistory} from 'react-router/es6';
-
-export default class SignupTeamComplete extends React.Component {
- constructor(props) {
- super(props);
-
- this.updateParent = this.updateParent.bind(this);
- }
- componentWillMount() {
- const data = JSON.parse(this.props.location.query.d);
- this.hash = this.props.location.query.h;
-
- var initialState = BrowserStore.getGlobalItem(this.hash);
-
- if (!initialState) {
- initialState = {};
- initialState.wizard = 'welcome';
- initialState.team = {};
- initialState.team.email = data.email;
- initialState.team.allowed_domains = '';
- initialState.invites = [];
- initialState.invites.push('');
- initialState.invites.push('');
- initialState.invites.push('');
- initialState.user = {};
- initialState.hash = this.hash;
- initialState.data = this.props.location.query.d;
- }
-
- this.setState(initialState);
- }
- componentDidMount() {
- browserHistory.push('/signup_team_complete/welcome');
- }
- updateParent(state, skipSet) {
- BrowserStore.setGlobalItem(this.hash, state);
-
- if (!skipSet) {
- this.setState(state);
- browserHistory.push('/signup_team_complete/' + state.wizard);
- }
- }
- render() {
- return (
- <div>
- <div className='signup-header'>
- <Link to='/'>
- <span className='fa fa-chevron-left'/>
- <FormattedMessage id='web.header.back'/>
- </Link>
- </div>
- <div className='col-sm-12'>
- <div className='signup-team__container'>
- <div id='signup-team-complete'>
- {React.cloneElement(this.props.children, {
- state: this.state,
- updateParent: this.updateParent
- })}
- </div>
- </div>
- </div>
- </div>
- );
- }
-}
-
-SignupTeamComplete.defaultProps = {
-};
-
-SignupTeamComplete.propTypes = {
- location: React.PropTypes.object,
- children: React.PropTypes.node
-};
diff --git a/webapp/tests/client_team.test.jsx b/webapp/tests/client_team.test.jsx
index 012259d0c..5fac2da6d 100644
--- a/webapp/tests/client_team.test.jsx
+++ b/webapp/tests/client_team.test.jsx
@@ -22,22 +22,6 @@ describe('Client.Team', function() {
});
});
- it('signupTeam', function(done) {
- var client = TestHelper.createClient();
- var email = TestHelper.fakeEmail();
-
- client.signupTeam(
- email,
- function(data) {
- assert.equal(data.email, email);
- done();
- },
- function(err) {
- done(new Error(err.message));
- }
- );
- });
-
it('createTeam', function(done) {
var client = TestHelper.createClient();
var team = TestHelper.fakeTeam();