Skip to content

Commit

Permalink
Merge pull request #946 from AgID/develop
Browse files Browse the repository at this point in the history
Consolidation in master
  • Loading branch information
pdavide authored Apr 7, 2021
2 parents 25eb0ba + 1784bff commit a522933
Show file tree
Hide file tree
Showing 24 changed files with 206 additions and 173 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ public function delete(PublicAdministration $publicAdministration, User $user)
}

Bouncer::scope()->onceTo($publicAdministration->id, function () use ($user) {
$user->abilities()->detach();
$user->roles()->detach();
$user->disallow($user->abilities->pluck('id'));
$user->retract($user->roles->pluck('name'));
});

$publicAdministration->users()->detach([$user->id]);
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public function storePrimary(StorePrimaryWebsiteRequest $request): RedirectRespo
'status' => PublicAdministrationStatus::PENDING,
]);

$publicAdministration->save();

$siteUrl = $request->isCustomPublicAdministration ? $request->publicAdministration['url'] : $request->publicAdministration['site'];
$website = $this->registerPublicAdministration($authUser, $publicAdministration, $siteUrl, $request->isCustomPublicAdministration, $request->input('email'));

Expand Down
2 changes: 1 addition & 1 deletion app/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function boot()

$view->with('bodyClasses', implode(' ', [
'wai',
$hasHighlightBar ? 'hasHighlightBar' : '',
$hasHighlightBar ? 'has-highlight-bar' : '',
]));
});
}
Expand Down
6 changes: 4 additions & 2 deletions app/Traits/ActivatesWebsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ public function activate(Website $website): void

$pendingUser = $publicAdministration->users()->where('user_status', UserStatus::PENDING)->first();
if ($pendingUser) {
// Detach UserRole::REGISTERED role from the pending user in the global scope
$pendingUser->roles()->detach();
// Retract UserRole::REGISTERED role from the pending user in the global scope
Bouncer::scope()->onceTo(0, function () use ($pendingUser) {
$pendingUser->retract(UserRole::REGISTERED);
});

Bouncer::scope()->to($publicAdministration->id);

Expand Down
9 changes: 7 additions & 2 deletions app/Traits/ManagePublicAdministrationRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected function registerPublicAdministration(User $user, PublicAdministration
{
$analyticsId = app()->make('analytics-service')->registerSite(__('Sito istituzionale'), $url, $publicAdministration->name);

$publicAdministration->save();
$website = Website::create([
'name' => $publicAdministration->name,
'url' => $url,
Expand All @@ -33,10 +32,16 @@ protected function registerPublicAdministration(User $user, PublicAdministration
]);

$publicAdministration->users()->save($user, ['user_email' => $userEmail, 'user_status' => UserStatus::PENDING]);

// Retract UserRole::REGISTERED role from the pending user in the global scope
Bouncer::scope()->onceTo(0, function () use ($user) {
$user->retract(UserRole::REGISTERED);
});

// This is the first time we know which public administration the
// current user belongs, so we need to set the tenant id just now.
session()->put('tenant_id', $publicAdministration->id);
$user->roles()->detach();

Bouncer::scope()->to($publicAdministration->id);
$user->assign(UserRole::REGISTERED);
if (!$user->hasAnalyticsServiceAccount()) {
Expand Down
2 changes: 2 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<token key="MATOMO_ROOT_APIKEY" value="${MATOMO_ROOT_APIKEY}" />
<token key="MATOMO_VERSION" value="${MATOMO_VERSION}" />
<token key="MATOMO_CRON_ARCHIVING_ENABLED" value="${MATOMO_CRON_ARCHIVING_ENABLED}" />
<token key="MATOMO_PHPREDIS_VERSION" value="${MATOMO_PHPREDIS_VERSION}" />
<token key="MATOMO_WAI_THEME_VERSION" value="${MATOMO_WAI_THEME_VERSION}" />
<token key="MATOMO_PLUGIN_USERSMANAGERONLYSUPERUSER_VERSION" value="${MATOMO_PLUGIN_USERSMANAGERONLYSUPERUSER_VERSION}" />
<token key="MATOMO_PLUGIN_USERSMANAGERONLYSUPERUSER_ENABLED" value="${MATOMO_PLUGIN_USERSMANAGERONLYSUPERUSER_ENABLED}" />
Expand Down Expand Up @@ -319,6 +320,7 @@
<echo msg="Create log directories if needed..."/>
<mkdir dir="containers/logs/nginx"/>
<mkdir dir="containers/logs/php"/>
<mkdir dir="containers/logs/mariadb"/>
<mkdir dir="containers/logs/matomo"/>
</else>
</if>
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "italia/wai-portal",
"description": "Web Analytics Italia",
"version": "1.6.2-beta",
"version": "1.6.3-beta",
"keywords": ["analytics", "italia"],
"license": "AGPL-3.0-or-later",
"type": "project",
Expand Down Expand Up @@ -38,7 +38,7 @@
"davejamesmiller/laravel-breadcrumbs": "^5.3",
"davidepastore/codice-fiscale": "^0.8.0",
"doctrine/dbal": "^2.10",
"elasticsearch/elasticsearch": "7.11.*",
"elasticsearch/elasticsearch": "7.12.*",
"ethanhann/redisearch-php": "^1.0",
"fideloper/proxy": "^4.2",
"guzzlehttp/guzzle": "^7.0",
Expand All @@ -64,7 +64,7 @@
"johnkary/phpunit-speedtrap": "^3.1",
"laravel/dusk": "^6.1",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^4.1",
"nunomaduro/collision": "^5.3",
"phing/phing": "2.*",
"phpunit/phpunit": "^9.0",
"shaggy8871/php-rx": "^1.0",
Expand Down
Loading

0 comments on commit a522933

Please sign in to comment.