Skip to content

Commit

Permalink
Merge pull request #589 from sammyskills/fix/update-groups-permission…
Browse files Browse the repository at this point in the history
…s-redirects

Fix: groups and permissions filter redirects
  • Loading branch information
datamweb authored Jan 12, 2023
2 parents dbb923f + 98d0d04 commit 2e582d9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 40 deletions.
6 changes: 0 additions & 6 deletions src/Filters/AbstractAuthFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ public function before(RequestInterface $request, $arguments = null)
return;
}

// If the previous_url is from this site, then
// we can redirect back to it.
if (strpos(previous_url(), site_url()) === 0) {
return redirect()->back()->with('error', lang('Auth.notEnoughPrivilege'));
}

// Otherwise, we'll just send them to the home page.
return redirect()->to('/')->with('error', lang('Auth.notEnoughPrivilege'));
}
Expand Down
17 changes: 0 additions & 17 deletions tests/Authentication/Filters/GroupFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,4 @@ public function testFilterIncorrectGroupNoPrevious(): void
// Should have error message
$result->assertSessionHas('error');
}

public function testFilterIncorrectGroupWithPrevious(): void
{
/** @var User $user */
$user = fake(UserModel::class);
$user->addGroup('beta');

$result = $this
->actingAs($user)
->withSession(['_ci_previous_url' => site_url('open-route')])
->get('protected-route');

// Should redirect to the previous url (open-route)
$result->assertRedirectTo(site_url('open-route'));

$result->assertSessionHas('error');
}
}
17 changes: 0 additions & 17 deletions tests/Authentication/Filters/PermissionFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,4 @@ public function testFilterIncorrectGroupNoPrevious(): void
// Should have error message
$result->assertSessionHas('error');
}

public function testFilterIncorrectGroupWithPrevious(): void
{
/** @var User $user */
$user = fake(UserModel::class);
$user->addPermission('beta.access');

$result = $this
->actingAs($user)
->withSession(['_ci_previous_url' => site_url('open-route')])
->get('protected-route');

// Should redirect to the previous url (open-route)
$result->assertRedirectTo(site_url('open-route'));

$result->assertSessionHas('error');
}
}

0 comments on commit 2e582d9

Please sign in to comment.