MM-10121: CLI command to reset permissions system to default state. (#8637)

* MM-10121: CLI command to reset permissions system to default state.

* Review comment.
Этот коммит содержится в:
George Goldberg
2018-04-18 10:18:07 +01:00
коммит произвёл GitHub
родитель a1882d4004
Коммит b13a228b04
17 изменённых файлов: 320 добавлений и 15 удалений

25
app/permissions.go Обычный файл
Просмотреть файл

@@ -0,0 +1,25 @@
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"github.com/mattermost/mattermost-server/model"
)
func (a *App) ResetPermissionsSystem() *model.AppError {
// Purge all roles from the database.
if result := <-a.Srv.Store.Role().PermanentDeleteAll(); result.Err != nil {
return result.Err
}
// Remove the "System" table entry that marks the advanced permissions migration as done.
if result := <-a.Srv.Store.System().PermanentDeleteByName(ADVANCED_PERMISSIONS_MIGRATION_KEY); result.Err != nil {
return result.Err
}
// Now that the permissions system has been reset, re-run the migration to reinitialise it.
a.DoAdvancedPermissionsMigration()
return nil
}