MM-14748: Allow to invalidate email invites (#10509)

This commit is contained in:
Jesús Espino
2019-03-26 19:30:49 +01:00
committed by GitHub
parent 3c8975780d
commit c370d30041
8 changed files with 87 additions and 15 deletions

View File

@@ -75,3 +75,12 @@ func (s SqlTokenStore) Cleanup() {
mlog.Error("Unable to cleanup token store.")
}
}
func (s SqlTokenStore) RemoveAllTokensByType(tokenType string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
if _, err := s.GetMaster().Exec("DELETE FROM Tokens WHERE Type = :TokenType", map[string]interface{}{"TokenType": tokenType}); err != nil {
result.Err = model.NewAppError("SqlTokenStore.RemoveAllTokensByType", "store.sql_recover.remove_all_tokens_by_type.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
})
}

View File

@@ -443,6 +443,7 @@ type TokenStore interface {
Delete(token string) StoreChannel
GetByToken(token string) StoreChannel
Cleanup()
RemoveAllTokensByType(tokenType string) StoreChannel
}
type EmojiStore interface {

View File

@@ -98,6 +98,22 @@ func (_m *PostStore) Get(id string) store.StoreChannel {
return r0
}
// GetDirectPostParentsForExportAfter provides a mock function with given fields: limit, afterId
func (_m *PostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) store.StoreChannel {
ret := _m.Called(limit, afterId)
var r0 store.StoreChannel
if rf, ok := ret.Get(0).(func(int, string) store.StoreChannel); ok {
r0 = rf(limit, afterId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
}
}
return r0
}
// GetEtag provides a mock function with given fields: channelId, allowFromCache
func (_m *PostStore) GetEtag(channelId string, allowFromCache bool) store.StoreChannel {
ret := _m.Called(channelId, allowFromCache)
@@ -470,18 +486,3 @@ func (_m *PostStore) Update(newPost *model.Post, oldPost *model.Post) store.Stor
return r0
}
func (_m *PostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) store.StoreChannel {
ret := _m.Called(limit, afterId)
var r0 store.StoreChannel
if rf, ok := ret.Get(0).(func(int, string) store.StoreChannel); ok {
r0 = rf(limit, afterId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
}
}
return r0
}

View File

@@ -7,6 +7,7 @@ package mocks
import gorp "github.com/mattermost/gorp"
import mock "github.com/stretchr/testify/mock"
import squirrel "github.com/Masterminds/squirrel"
import store "github.com/mattermost/mattermost-server/store"
// SqlStore is an autogenerated mock type for the SqlStore type
@@ -855,3 +856,17 @@ func (_m *SqlStore) Webhook() store.WebhookStore {
return r0
}
// getQueryBuilder provides a mock function with given fields:
func (_m *SqlStore) getQueryBuilder() squirrel.StatementBuilderType {
ret := _m.Called()
var r0 squirrel.StatementBuilderType
if rf, ok := ret.Get(0).(func() squirrel.StatementBuilderType); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(squirrel.StatementBuilderType)
}
return r0
}

View File

@@ -50,6 +50,22 @@ func (_m *TokenStore) GetByToken(token string) store.StoreChannel {
return r0
}
// RemoveAllTokensByType provides a mock function with given fields: tokenType
func (_m *TokenStore) RemoveAllTokensByType(tokenType string) store.StoreChannel {
ret := _m.Called(tokenType)
var r0 store.StoreChannel
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
r0 = rf(tokenType)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
}
}
return r0
}
// Save provides a mock function with given fields: recovery
func (_m *TokenStore) Save(recovery *model.Token) store.StoreChannel {
ret := _m.Called(recovery)