permission helpers
@@ -3,6 +3,7 @@ package contractpb
import (
"errors"
"fmt"
+ "log"
"time"
proto "github.com/gogo/protobuf/proto"
@@ -91,7 +92,8 @@ func (c *wrappedPluginContext) HasPermissionFor(addr loom.Address, token []byte,
foundRoles := []string{}
for _, role := range roles {
v := c.Context.Get(c.rolePermKey(addr, token, role))
- if v != nil && string(v) == role {
+ log.Printf("permission value %s:%s for %v on token %s\n", role, v, addr, token)
+ if v != nil && string(v) == "true" {
found = true
foundRoles = append(foundRoles, role)
}
@@ -111,6 +113,7 @@ func (c *wrappedPluginContext) rolePermKey(addr loom.Address, token []byte, role
// GrantPermission sets a given `role` permission on `token` for the sender of the tx
func (c *wrappedPluginContext) GrantPermission(token []byte, roles []string) {
for _, r := range roles {
+ log.Printf("Setting permission %s on %s for %v\b", r, token, c.Message().Sender)
c.GrantPermissionTo(c.Message().Sender, token, r)
}
}
