diff --git a/grails-app/conf/BootStrap.groovy b/grails-app/conf/BootStrap.groovy index a6619ab1c..76fff461a 100644 --- a/grails-app/conf/BootStrap.groovy +++ b/grails-app/conf/BootStrap.groovy @@ -988,7 +988,7 @@ gr_account.save(failOnError:true, flush:true) ), new Plan( name: "Testing", - max_organizations: 3, + max_organizations: 5, max_opts_per_organization: 3, max_api_tokens_per_organization: 3, repo_total_size_in_kb: 2000, // low for testing! (1MB in KB) diff --git a/grails-app/controllers/com/cabolabs/security/OrganizationController.groovy b/grails-app/controllers/com/cabolabs/security/OrganizationController.groovy index c1ef5a551..00645d58a 100644 --- a/grails-app/controllers/com/cabolabs/security/OrganizationController.groovy +++ b/grails-app/controllers/com/cabolabs/security/OrganizationController.groovy @@ -213,8 +213,9 @@ class OrganizationController { def commit_logs_repo = new File(config.commit_logs.withTrailSeparator() + organizationInstance.uid) commit_logs_repo.mkdir() - + + def accman_associated = false // prevents associating the accman twice if the current user is accman if (SpringSecurityUtils.ifAllGranted("ROLE_ADMIN")) { // assign org to admin only if admin choose to @@ -228,9 +229,20 @@ class OrganizationController { { // Assign org to logged user // uses the higher role on the current org to assign on the new org - UserRole.create( user, user.getHigherAuthority(session.organization), organizationInstance, true ) + def higher_role_in_current_org = user.getHigherAuthority(session.organization) + + UserRole.create( user, higher_role_in_current_org, organizationInstance, true ) + + if (higher_role_in_current_org.authority == Role.AM) accman_associated = true } + // create accman userrole for the account contact + if (!accman_associated) + { + UserRole.create( account.contact, (Role.findByAuthority(Role.AM)), organizationInstance, true ) + } + + flash.message = message(code: 'default.created.message', args: [message(code: 'organization.label', default: 'Organization'), organizationInstance.id]) redirect action:'show', params:[uid:organizationInstance.uid] }