working commit

This commit is contained in:
2026-06-09 14:10:53 +02:00
parent ee30858d11
commit 6e92720e69
26 changed files with 339 additions and 165 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ func (oper *Operator) ListAccounts(ctx context.Context, accountID string, params
}
for _, grantDescrs := range grantDescrs {
grantShortDescrs := &mbctl.GrantShortDescr{
Operation: grantDescrs.Operation,
Grantname: grantDescrs.Grantname,
CreatedAt: grantDescrs.CreatedAt,
}
accountShortDescr.Grants = append(accountShortDescr.Grants, grantShortDescrs)
+1 -1
View File
@@ -54,7 +54,7 @@ func (oper *Operator) SeedAccount(ctx context.Context) (string, error) {
for _, grantType := range grantTypes {
grantDescr := &descr.Grant{
AccountID: accountDescr.ID,
Operation: grantType,
Grantname: grantType,
CreatedAt: now,
}
err = oper.db.InsertGrant(ctx, grantDescr)
+1 -1
View File
@@ -96,7 +96,7 @@ func (oper *Operator) RestoreDump(ctx context.Context, accountID string, params
}
}
for _, grant := range dump.Grants {
oper.log.Infof("Insert grant %s for account %d", grant.Operation, grant.AccountID)
oper.log.Infof("Insert grant %s for account %d", grant.Grantname, grant.AccountID)
err = oper.db.InsertGrant(ctx, &grant)
if err != nil {
oper.log.Errorf("Insert account error: %v", err)
+7 -7
View File
@@ -31,7 +31,7 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
}
var grantOk bool
for _, grantType := range grantTypes {
if grantType == params.Operation {
if grantType == params.Grantname {
grantOk = true
break
}
@@ -60,12 +60,12 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
return res, err
}
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Operation)
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Grantname)
if err != nil {
return res, err
}
if grantExists {
err := fmt.Errorf("Grant %s for the user already exists", params.Operation)
err := fmt.Errorf("Grant %s for the user already exists", params.Grantname)
return res, err
}
now := time.Now().Format(time.RFC3339)
@@ -73,7 +73,7 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
CreatedAt: now,
Operation: params.Operation,
Grantname: params.Grantname,
}
err = oper.db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -103,7 +103,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
}
var grantOk bool
for _, grantType := range grantTypes {
if grantType == params.Operation {
if grantType == params.Grantname {
grantOk = true
break
}
@@ -132,7 +132,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
return res, err
}
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Operation)
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Grantname)
if err != nil {
return res, err
}
@@ -140,7 +140,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
err := fmt.Errorf("Requested grant for the user not found")
return res, err
}
err = oper.db.DeleteGrantByAccountID(ctx, accountDescr.ID, params.Operation)
err = oper.db.DeleteGrantByAccountID(ctx, accountDescr.ID, params.Grantname)
if err != nil {
return res, err
}