working commit
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user