Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Filters/SessionAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ public function before(RequestInterface $request, $arguments = null)
}

if ($user !== null && ! $user->isActivated()) {
$authenticator->logout();

return redirect()->route('login')
->with('error', lang('Auth.activationBlocked'));
// If an action has been defined for register, start it up.
$hasAction = $authenticator->startUpAction('register', $user);
if ($hasAction) {
return redirect()->route('auth-action-show')
->with('error', lang('Auth.activationBlocked'));
}
}

return;
Expand Down
1 change: 1 addition & 0 deletions tests/Authentication/Filters/AbstractFilterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static function ($routes): void {
echo 'Open';
});
$routes->get('login', 'AuthController::login', ['as' => 'login']);
$routes->get('auth/a/show', 'AuthActionController::show', ['as' => 'auth-action-show']);
$routes->get('protected-user-route', static function (): void {
echo 'Protected';
}, ['filter' => $this->alias . ':users-read']);
Expand Down
4 changes: 2 additions & 2 deletions tests/Authentication/Filters/SessionFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testRecordActiveDate(): void
$this->assertGreaterThan(auth('session')->user()->updated_at, auth('session')->user()->last_active);
}

public function testBlocksInactiveUsers(): void
public function testBlocksInactiveUsersAndRedirectsToAuthAction(): void
{
$user = fake(UserModel::class, ['active' => false]);

Expand All @@ -77,7 +77,7 @@ public function testBlocksInactiveUsers(): void
$result = $this->actingAs($user)
->get('protected-route');

$result->assertRedirectTo('/login');
$result->assertRedirectTo('/auth/a/show');
// User should be logged out
$this->assertNull(auth('session')->id());

Expand Down