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
+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
}