api/pkg/models/rights.go

44 lines
1.3 KiB
Go
Raw Normal View History

2020-02-07 16:27:45 +00:00
// Vikunja is a to-do list application to facilitate your life.
2021-02-02 19:19:13 +00:00
// Copyright 2018-2021 Vikunja and contributors. All rights reserved.
2018-11-26 20:17:33 +00:00
//
// This program is free software: you can redistribute it and/or modify
2020-12-23 15:41:52 +00:00
// it under the terms of the GNU Affero General Public Licensee as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2018-11-26 20:17:33 +00:00
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020-12-23 15:41:52 +00:00
// GNU Affero General Public Licensee for more details.
2018-11-26 20:17:33 +00:00
//
2020-12-23 15:41:52 +00:00
// You should have received a copy of the GNU Affero General Public Licensee
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-11-26 20:17:33 +00:00
2018-10-31 12:42:38 +00:00
package models
2022-11-13 16:07:01 +00:00
// Right defines the rights users/teams can have for projects/namespaces
type Right int
2018-10-31 12:42:38 +00:00
// define unknown right
2018-10-31 12:42:38 +00:00
const (
RightUnknown = -1
2018-10-31 12:42:38 +00:00
)
// Enumerate all the team rights
const (
2022-11-13 16:07:01 +00:00
// Can read projects in a
RightRead Right = iota
2022-11-13 16:07:01 +00:00
// Can write in a like projects and tasks. Cannot create new projects.
RightWrite
2022-11-13 16:07:01 +00:00
// Can manage a project/namespace, can do everything
RightAdmin
2018-10-31 12:42:38 +00:00
)
func (r Right) isValid() error {
if r != RightAdmin && r != RightRead && r != RightWrite {
return ErrInvalidRight{r}
2018-10-31 12:42:38 +00:00
}
return nil
}