Fix page redirect after changing an organisation name (slug) from the organisation info page (Fixes #9)

This commit is contained in:
2022-02-22 11:43:48 +00:00
parent 5f8e922438
commit e62e71ab6c
2 changed files with 17 additions and 4 deletions

View File

@@ -268,6 +268,8 @@ class OrganisationController extends SimpleController
return $response->withJson([], 400);
}
$oldSlug = $organisation->slug;
// Begin transaction - DB will be rolled back if an exception occurs
Capsule::transaction(function () use ($data, $organisation, $currentUser) {
// Update the organisation and generate success messages
@@ -290,7 +292,13 @@ class OrganisationController extends SimpleController
'name' => $organisation->name,
]);
return $response->withJson([], 200);
if ($oldSlug != $organisation->slug) {
return $response->withJson([
'redirect' => $this->ci->router->pathFor('uri_organisation', ['slug' => $organisation->slug])
], 200);
} else {
return $response->withJson([], 200);
}
}
/**
@@ -997,7 +1005,8 @@ class OrganisationController extends SimpleController
* @throws ForbiddenException If user is not authorized to access page
*/
public function pageInfo(Request $request, Response $response, $args)
{ /** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager $authorizer */
{
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager $authorizer */
$authorizer = $this->ci->authorizer;
/** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */