github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/app/permissions.go (about)

     1  // Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package app
     5  
     6  import (
     7  	"github.com/mattermost/mattermost-server/model"
     8  )
     9  
    10  func (a *App) ResetPermissionsSystem() *model.AppError {
    11  	// Purge all roles from the database.
    12  	if result := <-a.Srv.Store.Role().PermanentDeleteAll(); result.Err != nil {
    13  		return result.Err
    14  	}
    15  
    16  	// Remove the "System" table entry that marks the advanced permissions migration as done.
    17  	if result := <-a.Srv.Store.System().PermanentDeleteByName(ADVANCED_PERMISSIONS_MIGRATION_KEY); result.Err != nil {
    18  		return result.Err
    19  	}
    20  
    21  	// Now that the permissions system has been reset, re-run the migration to reinitialise it.
    22  	a.DoAdvancedPermissionsMigration()
    23  
    24  	return nil
    25  }