mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
24 lines
523 B
Go
24 lines
523 B
Go
|
package model
|
||
|
|
||
|
type Permissions struct {
|
||
|
Permissions []string
|
||
|
}
|
||
|
|
||
|
func (p *Permissions) AppendPermissions(ctxID string, permissions ...string) {
|
||
|
for _, permission := range permissions {
|
||
|
p.appendPermission(ctxID, permission)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p *Permissions) appendPermission(ctxID, permission string) {
|
||
|
if ctxID != "" {
|
||
|
permission = permission + ":" + ctxID
|
||
|
}
|
||
|
for _, existingPermission := range p.Permissions {
|
||
|
if existingPermission == permission {
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
p.Permissions = append(p.Permissions, permission)
|
||
|
}
|