/
wax_boy
/
semaphore_custom
Обзор
Документация
Войти
/
wax_boy
/
semaphore_custom
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
db/Role.go
33 строки
1 KB
Denis Gukov
fix: bug reports
19 июл 2026, 17:15
19 июл 2026, 17:15
048df99
Код
Авторство
О чём код?
package db import "github.com/semaphoreui/semaphore/pkg/common_errors" type Role struct { Slug string `db:"slug" json:"slug" backup:"-"` Name string `db:"name" json:"name"` Permissions ProjectUserPermission `db:"permissions" json:"permissions"` ProjectID *int `db:"project_id" json:"project_id"` } func ValidateRole(role Role) error { if role.Name == "" { return &common_errors.ValidationError{Message: "Role name cannot be empty"} } if role.Slug == "" { return &common_errors.ValidationError{Message: "Role slug cannot be empty"} } // Built-in role slugs are reserved. Allowing a custom role to reuse one lets // it shadow the built-in role and escalate the permissions of its members. if ProjectUserRole(role.Slug).IsValid() { return &common_errors.ValidationError{Message: "Role slug is reserved and cannot be used: " + role.Slug} } return nil } type TemplateRolePerm struct { ID int `db:"id" json:"id"` RoleSlug string `db:"role_slug" json:"role_slug"` TemplateID int `db:"template_id" json:"template_id"` ProjectID int `db:"project_id" json:"project_id"` Permissions ProjectUserPermission `db:"permissions" json:"permissions"` }