Added binding to tokens api and role validation

This commit is contained in:
Torkel Ödegaard
2015-01-16 12:06:24 +01:00
parent f858f6b621
commit 9feb8a73fd
6 changed files with 25 additions and 28 deletions
+2 -6
View File
@@ -19,12 +19,8 @@ const (
ROLE_ADMIN RoleType = "Admin"
)
func (r RoleType) Validate() error {
if r == ROLE_OWNER || r == ROLE_VIEWER || r == ROLE_ADMIN || r == ROLE_EDITOR {
return nil
}
return ErrInvalidRoleType
func (r RoleType) IsValid() bool {
return r == ROLE_VIEWER || r == ROLE_ADMIN || r == ROLE_EDITOR
}
type Collaborator struct {
+6 -5
View File
@@ -25,11 +25,12 @@ type AddTokenCommand struct {
}
type UpdateTokenCommand struct {
Id int64 `json:"id"`
Name string `json:"name"`
AccountId int64 `json:"-"`
Role RoleType `json:"role"`
Result *Token `json:"-"`
Id int64 `json:"id"`
Name string `json:"name"`
Role RoleType `json:"role"`
AccountId int64 `json:"-"`
Result *Token `json:"-"`
}
type DeleteTokenCommand struct {