mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
fix: Add service to database when registering
This commit is contained in:
committed by
Prad Nukala (aider)
parent
1810ee1c7f
commit
861fbf501d
+10
-7
@@ -45,20 +45,23 @@ func (ms msgServer) RegisterController(goCtx context.Context, msg *types.MsgRegi
|
||||
if ms.k.authority != msg.Authority {
|
||||
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority)
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
svc := didv1.Service{
|
||||
ControllerDid: msg.Authority,
|
||||
}
|
||||
ms.k.OrmDB.ServiceTable().Insert(ctx, &svc)
|
||||
return &types.MsgRegisterControllerResponse{}, nil
|
||||
}
|
||||
|
||||
// RegisterService implements types.MsgServer.
|
||||
func (ms msgServer) RegisterService(ctx context.Context, msg *types.MsgRegisterService) (*types.MsgRegisterServiceResponse, error) {
|
||||
func (ms msgServer) RegisterService(goCtx context.Context, msg *types.MsgRegisterService) (*types.MsgRegisterServiceResponse, error) {
|
||||
if ms.k.authority != msg.Authority {
|
||||
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority)
|
||||
}
|
||||
// ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
svc := didv1.Service{
|
||||
ControllerDid: msg.Authority,
|
||||
}
|
||||
err := ms.k.OrmDB.ServiceTable().Insert(ctx, &svc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgRegisterServiceResponse{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package types
|
||||
|
||||
import "gopkg.in/macaroon-bakery.v2/bakery/checkers"
|
||||
|
||||
var (
|
||||
PermissionScopeStrings = [...]string{
|
||||
"profile.name",
|
||||
@@ -36,18 +34,3 @@ var (
|
||||
"PERMISSION_SCOPE_ADMIN_VALIDATOR": PermissionScope_PERMISSION_SCOPE_ADMIN_VALIDATOR,
|
||||
}
|
||||
)
|
||||
|
||||
func ResolvePermissionScope(scope string) (PermissionScope, bool) {
|
||||
uriToPrefix := make(map[string]string)
|
||||
for _, scope := range PermissionScopeStrings {
|
||||
uriToPrefix["https://example.com/auth/"+scope] = scope
|
||||
}
|
||||
PermissionNamespace := checkers.NewNamespace(uriToPrefix)
|
||||
|
||||
prefix, ok := PermissionNamespace.Resolve("https://example.com/auth/" + scope)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
permScope, ok := StringToPermissionScope[prefix]
|
||||
return permScope, ok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user