Skip to content

Commit

Permalink
Merge branch 'feat/auth-token' into feat/sdk-pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodek committed Jun 19, 2024
2 parents 5030259 + 9bc6b98 commit cde5d71
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions x/acp/keeper/msg_server_bearer_policy_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo
if err != nil {
return nil, err
}

resolver := &did.KeyResolver{}
authorizer := relationship.NewRelationshipAuthorizer(engine)

actorID, err := bearer_token.AuthorizeMsg(ctx, resolver, msg, ctx.BlockTime())
if err != nil {
return nil, err
}

authorizer := relationship.NewRelationshipAuthorizer(engine)

rec, err := engine.GetPolicy(goCtx, msg.PolicyId)
if err != nil {
return nil, err
} else if rec == nil {
return nil, fmt.Errorf("PolcyCmd: policy %v: %w", msg.PolicyId, types.ErrPolicyNotFound)
}

result := &types.MsgBearerPolicyCmdResponse{}
cmdResult := &types.PolicyCmdResult{}
policy := rec.Policy

switch c := msg.Cmd.Cmd.(type) {
Expand All @@ -56,7 +55,7 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo
break
}

result.Result.Result = &types.PolicyCmdResult_SetRelationshipResult{
cmdResult.Result = &types.PolicyCmdResult_SetRelationshipResult{
SetRelationshipResult: &types.SetRelationshipCmdResult{
RecordExisted: bool(found),
Record: record,
Expand All @@ -76,7 +75,7 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo
break
}

result.Result.Result = &types.PolicyCmdResult_DeleteRelationshipResult{
cmdResult.Result = &types.PolicyCmdResult_DeleteRelationshipResult{
DeleteRelationshipResult: &types.DeleteRelationshipCmdResult{
RecordFound: bool(found),
},
Expand All @@ -102,7 +101,7 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo
break
}

result.Result.Result = &types.PolicyCmdResult_RegisterObjectResult{
cmdResult.Result = &types.PolicyCmdResult_RegisterObjectResult{
RegisterObjectResult: &types.RegisterObjectCmdResult{
Result: registrationResult,
Record: record,
Expand All @@ -122,7 +121,7 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo
break
}

result.Result.Result = &types.PolicyCmdResult_UnregisterObjectResult{
cmdResult.Result = &types.PolicyCmdResult_UnregisterObjectResult{
UnregisterObjectResult: &types.UnregisterObjectCmdResult{
Found: true, //TODO true,
RelationshipsRemoved: uint64(count),
Expand All @@ -138,5 +137,7 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo

}

return result, nil
return &types.MsgBearerPolicyCmdResponse{
Result: cmdResult,
}, nil
}

0 comments on commit cde5d71

Please sign in to comment.