Assign user role to newly created accounts.

https://github.com/owncloud/product/issues/173
This commit is contained in:
Ilja Neumann
2020-08-26 16:21:04 +02:00
committed by Ilja Neumann
parent 453a9ff1c7
commit f552072608
2 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
Change: Create account api-call implicitly adds "default-user" role
When calling CreateAccount default-user-role is implicitly added.
https://github.com/owncloud/product/issues/173

View File

@@ -19,9 +19,12 @@ import (
"github.com/blevesearch/bleve"
"github.com/gofrs/uuid"
"github.com/golang/protobuf/ptypes/empty"
mgrpc "github.com/micro/go-micro/v2/client/grpc"
merrors "github.com/micro/go-micro/v2/errors"
"github.com/owncloud/ocis-accounts/pkg/proto/v0"
"github.com/owncloud/ocis-accounts/pkg/provider"
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
settings_svc "github.com/owncloud/ocis-settings/pkg/service/v0"
"github.com/tredoe/osutil/user/crypt"
"google.golang.org/protobuf/types/known/timestamppb"
@@ -320,6 +323,17 @@ func (s Service) CreateAccount(c context.Context, in *proto.CreateAccountRequest
return
}
// TODO: All users for now as create Account request does not have any role field
rs := settings.NewRoleService("com.owncloud.api.settings", mgrpc.NewClient())
_, err = rs.AssignRoleToUser(c, &settings.AssignRoleToUserRequest{
AccountUuid: acc.Id,
RoleId: settings_svc.BundleUUIDRoleUser,
})
if err != nil {
return merrors.InternalServerError(s.id, "could not assign role to account: %v", err.Error())
}
if err = s.indexAccount(acc.Id); err != nil {
return merrors.InternalServerError(s.id, "could not index new account: %v", err.Error())
}