working commit
This commit is contained in:
+15
-15
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
"mstore/pkg/client"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -126,8 +126,8 @@ type CreateAccountParams struct {
|
||||
NewPassword string
|
||||
}
|
||||
type CreateAccountResult struct {
|
||||
AccountID uuid.UUID `yaml:"accountId"`
|
||||
Grants map[uuid.UUID]terms.Right `yaml:"grantsIds,omitempty"`
|
||||
AccountID uuid.UUID `yaml:"accountId"`
|
||||
Grants map[uuid.UUID]term.Right `yaml:"grantsIds,omitempty"`
|
||||
}
|
||||
|
||||
func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
|
||||
@@ -141,7 +141,7 @@ func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
|
||||
func (util *AccountUtil) createAccount(common *CommonAccountParams, params *CreateAccountParams) (*CreateAccountResult, error) {
|
||||
var err error
|
||||
res := &CreateAccountResult{
|
||||
Grants: make(map[uuid.UUID]terms.Right, 0),
|
||||
Grants: make(map[uuid.UUID]term.Right, 0),
|
||||
}
|
||||
hostname, err := packUserinfo(common.Hostname, common.Username, common.Password)
|
||||
if err != nil {
|
||||
@@ -154,13 +154,13 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
|
||||
return res, err
|
||||
}
|
||||
|
||||
fullRights := []terms.Right{
|
||||
terms.RightWriteAccounts,
|
||||
terms.RightReadAccounts,
|
||||
terms.RightWriteFiles,
|
||||
terms.RightReadFiles,
|
||||
terms.RightWriteImages,
|
||||
terms.RightReadImages,
|
||||
fullRights := []term.Right{
|
||||
term.RightWriteAccounts,
|
||||
term.RightReadAccounts,
|
||||
term.RightWriteFiles,
|
||||
term.RightReadFiles,
|
||||
term.RightWriteImages,
|
||||
term.RightReadImages,
|
||||
}
|
||||
for _, right := range fullRights {
|
||||
id, err := client.NewClient().CreateGrantByAccountID(ctx, hostname, accountID, right, ".*")
|
||||
@@ -299,9 +299,9 @@ type ListAccountsParams struct {
|
||||
}
|
||||
|
||||
type Userinfo struct {
|
||||
Username string `yaml:"username,omitempty"`
|
||||
AccountID uuid.UUID `yaml:"accountId,omitempty"`
|
||||
Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"`
|
||||
Username string `yaml:"username,omitempty"`
|
||||
AccountID uuid.UUID `yaml:"accountId,omitempty"`
|
||||
Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
|
||||
}
|
||||
|
||||
type ListAccountsResult struct {
|
||||
@@ -350,7 +350,7 @@ func (util *AccountUtil) listAccounts(common *CommonAccountParams, params *ListA
|
||||
userinfo := Userinfo{
|
||||
Username: account.Username,
|
||||
AccountID: account.ID,
|
||||
Rights: make(map[uuid.UUID]terms.Right, 0),
|
||||
Rights: make(map[uuid.UUID]term.Right, 0),
|
||||
}
|
||||
for _, grant := range account.Grants {
|
||||
userinfo.Rights[grant.ID] = grant.Right
|
||||
|
||||
Reference in New Issue
Block a user