Avoid repeated default role assignments

When using the metadata storage (the current default) the default role
assignments were recreated at every start of the settings service. Leading to
duplicated role assignments

Fixes: #3432
This commit is contained in:
Ralf Haferkamp
2023-03-14 16:08:37 +01:00
parent b041995734
commit dbe40bd7c7
2 changed files with 16 additions and 0 deletions
@@ -0,0 +1,6 @@
Bugfix: Fix default role assignment for demo users
The roles-assignments for demo users where duplicated with every
restart of the settings service.
https://github.com/owncloud/ocis/issues/3432
@@ -131,11 +131,21 @@ func (s *Store) initMetadataClient(mdc MetadataClient) error {
return err
}
assIDs, err := mdc.ReadDir(ctx, accountPath(accountUUID))
if err != nil {
return err
}
if len(assIDs) > 0 {
// There is already a role assignment for this ID, skip to the next
continue
}
ass := &settingsmsg.UserRoleAssignment{
Id: uuid.Must(uuid.NewV4()).String(),
AccountUuid: accountUUID,
RoleId: roleID,
}
b, err := json.Marshal(ass)
if err != nil {
return err