From fb9a6c76113e5913d2ad7edb595a05e8567a3e85 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 11 Mar 2016 10:48:43 -0500 Subject: Auto-create account if team allows sign-up from login page and oauth account doesn't exist --- api/user.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'api') diff --git a/api/user.go b/api/user.go index b7e6220d8..353fdff3e 100644 --- a/api/user.go +++ b/api/user.go @@ -246,7 +246,7 @@ func CreateUser(team *model.Team, user *model.User) (*model.User, *model.AppErro } } -func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.ReadCloser, team *model.Team) *model.User { +func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.Reader, team *model.Team) *model.User { var user *model.User provider := einterfaces.GetOauthProvider(service) if provider == nil { @@ -478,7 +478,10 @@ func LoginByUsername(c *Context, w http.ResponseWriter, r *http.Request, usernam return nil } -func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.ReadCloser, team *model.Team) *model.User { +func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.Reader, team *model.Team) *model.User { + buf := bytes.Buffer{} + buf.ReadFrom(userData) + authData := "" provider := einterfaces.GetOauthProvider(service) if provider == nil { @@ -486,7 +489,7 @@ func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service st map[string]interface{}{"Service": service}, "") return nil } else { - authData = provider.GetAuthDataFromJson(userData) + authData = provider.GetAuthDataFromJson(bytes.NewReader(buf.Bytes())) } if len(authData) == 0 { @@ -497,6 +500,9 @@ func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service st var user *model.User if result := <-Srv.Store.User().GetByAuth(team.Id, authData, service); result.Err != nil { + if result.Err.Id == store.MISSING_AUTH_ACCOUNT_ERROR && team.AllowOpenInvite { + return CreateOAuthUser(c, w, r, service, bytes.NewReader(buf.Bytes()), team) + } c.Err = result.Err return nil } else { -- cgit v1.2.3-1-g7c22 From 64f9b7ec089f56303b5eca696fff741f6618952b Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Wed, 16 Mar 2016 09:38:35 -0700 Subject: PLT-2344 support 3 versions back --- api/command_loadtest_test.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'api') diff --git a/api/command_loadtest_test.go b/api/command_loadtest_test.go index 1debc766a..ef370cf19 100644 --- a/api/command_loadtest_test.go +++ b/api/command_loadtest_test.go @@ -201,21 +201,23 @@ func TestLoadTestUrlCommands(t *testing.T) { t.Fatal("/loadtest url for README.md should've executed") } - command = "/loadtest url test-emoticons1.md" - if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." { - t.Fatal("/loadtest url for test-emoticons.md should've executed") - } - - command = "/loadtest url test-emoticons1" - if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." { - t.Fatal("/loadtest url for test-emoticons should've executed") - } - - posts := Client.Must(Client.GetPosts(channel.Id, 0, 5, "")).Data.(*model.PostList) - // note that this may make more than 3 posts if files are too long to fit in an individual post - if len(posts.Order) < 3 { - t.Fatal("/loadtest url made too few posts, perhaps there needs to be a delay before GetPosts in the test?") - } + // Removing these tests since they break compatibilty with previous release branches because the url pulls from github master + + // command = "/loadtest url test-emoticons1.md" + // if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." { + // t.Fatal("/loadtest url for test-emoticons.md should've executed") + // } + + // command = "/loadtest url test-emoticons1" + // if r := Client.Must(Client.Command(channel.Id, command, false)).Data.(*model.CommandResponse); r.Text != "Loading data..." { + // t.Fatal("/loadtest url for test-emoticons should've executed") + // } + + // posts := Client.Must(Client.GetPosts(channel.Id, 0, 5, "")).Data.(*model.PostList) + // // note that this may make more than 3 posts if files are too long to fit in an individual post + // if len(posts.Order) < 3 { + // t.Fatal("/loadtest url made too few posts, perhaps there needs to be a delay before GetPosts in the test?") + // } time.Sleep(2 * time.Second) } -- cgit v1.2.3-1-g7c22 From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- api/file_test.go | 6 +++--- api/user.go | 2 +- api/user_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'api') diff --git a/api/file_test.go b/api/file_test.go index c3ece7199..4a3eaebfb 100644 --- a/api/file_test.go +++ b/api/file_test.go @@ -43,7 +43,7 @@ func TestUploadFile(t *testing.T) { t.Fatal(err) } - path := utils.FindDir("web/static/images") + path := utils.FindDir("tests") file, err := os.Open(path + "/test.png") defer file.Close() @@ -159,7 +159,7 @@ func TestGetFile(t *testing.T) { t.Fatal(err) } - path := utils.FindDir("web/static/images") + path := utils.FindDir("tests") file, err := os.Open(path + "/test.png") if err != nil { t.Fatal(err) @@ -342,7 +342,7 @@ func TestGetPublicLink(t *testing.T) { t.Fatal(err) } - path := utils.FindDir("web/static/images") + path := utils.FindDir("tests") file, err := os.Open(path + "/test.png") if err != nil { t.Fatal(err) diff --git a/api/user.go b/api/user.go index 0841c38aa..2c8185209 100644 --- a/api/user.go +++ b/api/user.go @@ -1049,7 +1049,7 @@ func createProfileImage(username string, userId string) ([]byte, *model.AppError initial := string(strings.ToUpper(username)[0]) - fontBytes, err := ioutil.ReadFile(utils.FindDir("web/static/fonts") + utils.Cfg.FileSettings.InitialFont) + fontBytes, err := ioutil.ReadFile(utils.FindDir("fonts") + utils.Cfg.FileSettings.InitialFont) if err != nil { return nil, model.NewLocAppError("createProfileImage", "api.user.create_profile_image.default_font.app_error", nil, err.Error()) } diff --git a/api/user_test.go b/api/user_test.go index 27f00829f..a175adb1b 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -470,7 +470,7 @@ func TestUserUploadProfileImage(t *testing.T) { t.Fatal(err) } - path := utils.FindDir("web/static/images") + path := utils.FindDir("tests") file, err := os.Open(path + "/test.png") if err != nil { t.Fatal(err) -- cgit v1.2.3-1-g7c22