mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-02 02:11:18 -06:00
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:
6
changelog/unreleased/fix-duplicated-demouser-roles.md
Normal file
6
changelog/unreleased/fix-duplicated-demouser-roles.md
Normal file
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user