From 94f8be51f91203d5d6ccbd99dd721b7e945791bf Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 12 May 2016 21:35:55 -0400 Subject: Properly updated FilteredUserList when the provided user list is changed (#2983) --- webapp/components/filtered_user_list.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webapp/components/filtered_user_list.jsx b/webapp/components/filtered_user_list.jsx index 4270d3731..fca68a81a 100644 --- a/webapp/components/filtered_user_list.jsx +++ b/webapp/components/filtered_user_list.jsx @@ -43,6 +43,15 @@ class FilteredUserList extends React.Component { }; } + componentWillUpdate(nextProps) { + // assume the user list is immutable + if (this.props.users !== nextProps.users) { + this.setState({ + users: this.filterUsers(nextProps.teamMembers, nextProps.users) + }); + } + } + componentDidUpdate(prevProps, prevState) { if (prevState.filter !== this.state.filter) { $(ReactDOM.findDOMNode(this.refs.userList)).scrollTop(0); -- cgit v1.2.3-1-g7c22 From 4f22cbc92bf131fe37dbed43a4154a43e344d8cf Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 12 May 2016 21:36:02 -0400 Subject: Stopped login code from falling back to LDAP when it's disabled (#2986) --- api/authentication.go | 2 +- api/user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/authentication.go b/api/authentication.go index 9243947ad..d30fc0a1f 100644 --- a/api/authentication.go +++ b/api/authentication.go @@ -127,7 +127,7 @@ func checkUserNotDisabled(user *model.User) *model.AppError { } func authenticateUser(user *model.User, password, mfaToken string) (*model.User, *model.AppError) { - ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil + ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed && *utils.License.Features.LDAP if user.AuthService == model.USER_AUTH_SERVICE_LDAP { if !ldapAvailable { diff --git a/api/user.go b/api/user.go index 9e93ae779..559cda076 100644 --- a/api/user.go +++ b/api/user.go @@ -487,7 +487,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) { } func getUserForLogin(loginId string, onlyLdap bool) (*model.User, *model.AppError) { - ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil + ldapAvailable := *utils.Cfg.LdapSettings.Enable && einterfaces.GetLdapInterface() != nil && utils.IsLicensed && *utils.License.Features.LDAP if result := <-Srv.Store.User().GetForLogin( loginId, -- cgit v1.2.3-1-g7c22 From e46c1b8d52dce75a442b42c40803a071532676d7 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 12 May 2016 21:36:15 -0400 Subject: Inlcude team Id for fake context for incoming webhooks (#2988) --- api/webhook.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/webhook.go b/api/webhook.go index a4367026f..11456d69e 100644 --- a/api/webhook.go +++ b/api/webhook.go @@ -434,6 +434,8 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) { IsOAuth: false, } + c.TeamId = hook.TeamId + if !c.HasPermissionsToChannel(pchan, "createIncomingHook") && channel.Type != model.CHANNEL_OPEN { c.Err = model.NewLocAppError("incomingWebhook", "web.incoming_webhook.permissions.app_error", nil, "") return -- cgit v1.2.3-1-g7c22 From 9d94869cc6a0fb9f051879437c104ccd76094380 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 12 May 2016 18:36:30 -0700 Subject: Fixing issue with missing user (#2989) --- api/team.go | 4 ++++ store/sql_user_store.go | 23 ++++++++++++++++++++++- store/sql_user_store_test.go | 24 ++++++++++++++++++++++++ store/store.go | 1 + 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/api/team.go b/api/team.go index f9b718e06..52d01b1cc 100644 --- a/api/team.go +++ b/api/team.go @@ -266,6 +266,10 @@ func JoinUserToTeam(team *model.Team, user *model.User) *model.AppError { return tmr.Err } + if uua := <-Srv.Store.User().UpdateUpdateAt(user.Id); uua.Err != nil { + return uua.Err + } + // Soft error if there is an issue joining the default channels if err := JoinDefaultChannels(team.Id, user, channelRole); err != nil { l4g.Error(utils.T("api.user.create_user.joining.error"), user.Id, team.Id, err) diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 080d8d128..a6b706380 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -197,6 +197,27 @@ func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel { return storeChannel } +func (us SqlUserStore) UpdateUpdateAt(userId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + curTime := model.GetMillis() + + if _, err := us.GetMaster().Exec("UPDATE Users SET UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": curTime, "UserId": userId}); err != nil { + result.Err = model.NewLocAppError("SqlUserStore.UpdateUpdateAt", "store.sql_user.update_update.app_error", nil, "user_id="+userId) + } else { + result.Data = userId + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (us SqlUserStore) UpdateLastPingAt(userId string, time int64) StoreChannel { storeChannel := make(StoreChannel) @@ -461,7 +482,7 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel { WHERE UserId = :UserId AND Category = 'direct_channel_show') - ORDER BY UpdateAt DESC + ORDER BY UpdateAt DESC LIMIT 1 `, map[string]interface{}{"UserId": userId}) if err != nil { result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis()) diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go index 5c33ea0f1..b6cfbb0ec 100644 --- a/store/sql_user_store_test.go +++ b/store/sql_user_store_test.go @@ -105,6 +105,30 @@ func TestUserStoreUpdate(t *testing.T) { } } +func TestUserStoreUpdateUpdateAt(t *testing.T) { + Setup() + + u1 := &model.User{} + u1.Email = model.NewId() + Must(store.User().Save(u1)) + Must(store.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + + time.Sleep(10 * time.Millisecond) + + if err := (<-store.User().UpdateUpdateAt(u1.Id)).Err; err != nil { + t.Fatal(err) + } + + if r1 := <-store.User().Get(u1.Id); r1.Err != nil { + t.Fatal(r1.Err) + } else { + if r1.Data.(*model.User).UpdateAt <= u1.UpdateAt { + t.Fatal("UpdateAt not updated correctly") + } + } + +} + func TestUserStoreUpdateLastPingAt(t *testing.T) { Setup() diff --git a/store/store.go b/store/store.go index 37aafdd4a..7f62fcd97 100644 --- a/store/store.go +++ b/store/store.go @@ -122,6 +122,7 @@ type UserStore interface { Save(user *model.User) StoreChannel Update(user *model.User, allowRoleUpdate bool) StoreChannel UpdateLastPictureUpdate(userId string) StoreChannel + UpdateUpdateAt(userId string) StoreChannel UpdateLastPingAt(userId string, time int64) StoreChannel UpdateLastActivityAt(userId string, time int64) StoreChannel UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel -- cgit v1.2.3-1-g7c22