app: add permissions wrapper (#20242)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0dd1969bd5
Коммит
9985e22dab
@@ -219,6 +219,10 @@ func NewChannels(s *Server, services map[ServiceKey]interface{}) (*Channels, err
|
|||||||
app: &App{ch: ch},
|
app: &App{ch: ch},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
services[PermissionsKey] = &permissionsServiceWrapper{
|
||||||
|
app: &App{ch: ch},
|
||||||
|
}
|
||||||
|
|
||||||
return ch, nil
|
return ch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ import (
|
|||||||
const permissionsExportBatchSize = 100
|
const permissionsExportBatchSize = 100
|
||||||
const systemSchemeName = "00000000-0000-0000-0000-000000000000" // Prevents collisions with user-created schemes.
|
const systemSchemeName = "00000000-0000-0000-0000-000000000000" // Prevents collisions with user-created schemes.
|
||||||
|
|
||||||
|
type permissionsServiceWrapper struct {
|
||||||
|
app AppIface
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *permissionsServiceWrapper) HasPermissionToTeam(userID string, teamID string, permission *model.Permission) bool {
|
||||||
|
return s.app.HasPermissionToTeam(userID, teamID, permission)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) ResetPermissionsSystem() *model.AppError {
|
func (a *App) ResetPermissionsSystem() *model.AppError {
|
||||||
// Reset all Teams to not have a scheme.
|
// Reset all Teams to not have a scheme.
|
||||||
if err := a.Srv().Store.Team().ResetAllTeamSchemes(); err != nil {
|
if err := a.Srv().Store.Team().ResetAllTeamSchemes(); err != nil {
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ const (
|
|||||||
ClusterKey ServiceKey = "cluster"
|
ClusterKey ServiceKey = "cluster"
|
||||||
PostKey ServiceKey = "post"
|
PostKey ServiceKey = "post"
|
||||||
TeamKey ServiceKey = "team"
|
TeamKey ServiceKey = "team"
|
||||||
|
PermissionsKey ServiceKey = "permissions"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user