From 635628cf30460a75d3a870394ad66db91f3bea9f Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 4 Jan 2017 14:11:48 -0500 Subject: Removing old signup team API (#4950) --- api/team.go | 52 ---------------------------------------------------- api/team_test.go | 11 ----------- api/user.go | 2 +- 3 files changed, 1 insertion(+), 64 deletions(-) (limited to 'api') 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 } -- cgit v1.2.3-1-g7c22