Lower case email before database queries (#2689)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
158596deb8
Коммит
a9bd9843d4
@@ -6,6 +6,7 @@ package store
|
||||
import (
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SqlTeamStore struct {
|
||||
@@ -223,6 +224,8 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
email = strings.ToLower(email)
|
||||
|
||||
var data []*model.Team
|
||||
if _, err := s.GetReplica().Select(&data, "SELECT Teams.* FROM Teams, Users WHERE Teams.Id = Users.TeamId AND Users.Email = :Email", map[string]interface{}{"Email": email}); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlTeamStore.GetTeamsForEmail", "store.sql_team.get_teams_for_email.app_error", nil, "email="+email+", "+err.Error())
|
||||
|
||||
@@ -320,6 +320,8 @@ func (us SqlUserStore) UpdateAuthData(userId, service, authData, email string) S
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
email = strings.ToLower(email)
|
||||
|
||||
updateAt := model.GetMillis()
|
||||
|
||||
query := `
|
||||
@@ -508,6 +510,8 @@ func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel {
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
email = strings.ToLower(email)
|
||||
|
||||
user := model.User{}
|
||||
|
||||
if err := us.GetReplica().SelectOne(&user, "SELECT * FROM Users WHERE TeamId = :TeamId AND Email = :Email", map[string]interface{}{"TeamId": teamId, "Email": email}); err != nil {
|
||||
@@ -666,7 +670,7 @@ func (us SqlUserStore) PermanentDelete(userId string) StoreChannel {
|
||||
result := StoreResult{}
|
||||
|
||||
if _, err := us.GetMaster().Exec("DELETE FROM Users WHERE Id = :UserId", map[string]interface{}{"UserId": userId}); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlUserStore.GetByEmail", "store.sql_user.permanent_delete.app_error", nil, "userId="+userId+", "+err.Error())
|
||||
result.Err = model.NewLocAppError("SqlUserStore.PermanentDelete", "store.sql_user.permanent_delete.app_error", nil, "userId="+userId+", "+err.Error())
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
|
||||
Ссылка в новой задаче
Block a user