[MM-56061] Only render where field in model.AppError when it's present (#25648)
* Only render where field in model.AppError when it's present * Remove trailing comma from permission error
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a54f927e3d
Коммит
5b6b425cfc
@@ -3,6 +3,10 @@
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
PermissionScopeSystem = "system_scope"
|
||||
PermissionScopeTeam = "team_scope"
|
||||
@@ -2455,3 +2459,14 @@ func initializePermissions() {
|
||||
func init() {
|
||||
initializePermissions()
|
||||
}
|
||||
|
||||
func MakePermissionError(s *Session, permissions []*Permission) *AppError {
|
||||
permissionsStr := "permission="
|
||||
for i, permission := range permissions {
|
||||
permissionsStr += permission.Id
|
||||
if i != len(permissions)-1 {
|
||||
permissionsStr += ","
|
||||
}
|
||||
}
|
||||
return NewAppError("Permissions", "api.context.permissions.app_error", nil, "userId="+s.UserId+", "+permissionsStr, http.StatusForbidden)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user