mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Moved add collaborator to command way of doing it
This commit is contained in:
@@ -6,12 +6,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
SaveAccount func(account *Account) error
|
||||
GetAccountByLogin func(emailOrName string) (*Account, error)
|
||||
GetAccount func(accountId int64) (*Account, error)
|
||||
GetOtherAccountsFor func(accountId int64) ([]*OtherAccount, error)
|
||||
GetCollaboratorsForAccount func(accountId int64) ([]*CollaboratorInfo, error)
|
||||
AddCollaborator func(collaborator *Collaborator) error
|
||||
SaveAccount func(account *Account) error
|
||||
GetAccountByLogin func(emailOrName string) (*Account, error)
|
||||
GetAccount func(accountId int64) (*Account, error)
|
||||
GetOtherAccountsFor func(accountId int64) ([]*OtherAccount, error)
|
||||
)
|
||||
|
||||
// Typed errors
|
||||
@@ -30,7 +28,7 @@ type Account struct {
|
||||
Id int64
|
||||
Login string `xorm:"UNIQUE NOT NULL"`
|
||||
Email string `xorm:"UNIQUE NOT NULL"`
|
||||
Name string `xorm:"UNIQUE NOT NULL"`
|
||||
Name string
|
||||
FullName string
|
||||
Password string
|
||||
IsAdmin bool
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ROLE_READ_WRITE = "ReadWrite"
|
||||
ROLE_READ = "Read"
|
||||
ROLE_READ_WRITE RoleType = "ReadWrite"
|
||||
ROLE_READ = "Read"
|
||||
)
|
||||
|
||||
type RoleType string
|
||||
@@ -16,15 +16,16 @@ type Collaborator struct {
|
||||
AccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"` // The account that can use another account
|
||||
Role RoleType `xorm:"not null"` // Permission type
|
||||
ForAccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"` // The account being given access to
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
// read only projection
|
||||
type CollaboratorInfo struct {
|
||||
AccountId int64
|
||||
Role string
|
||||
Email string
|
||||
type AddCollaboratorCommand struct {
|
||||
Email string `json:"email" binding:"required"`
|
||||
AccountId int64 `json:"-"`
|
||||
ForAccountId int64 `json:"-"`
|
||||
Role RoleType `json:"-"`
|
||||
}
|
||||
|
||||
func NewCollaborator(accountId int64, forAccountId int64, role RoleType) *Collaborator {
|
||||
|
||||
Reference in New Issue
Block a user