diff --git a/src/Filters/SessionAuth.php b/src/Filters/SessionAuth.php index 6a8a0d8fe..b7d449666 100644 --- a/src/Filters/SessionAuth.php +++ b/src/Filters/SessionAuth.php @@ -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; diff --git a/tests/Authentication/Filters/AbstractFilterTestCase.php b/tests/Authentication/Filters/AbstractFilterTestCase.php index 23ece0925..d44f9e931 100644 --- a/tests/Authentication/Filters/AbstractFilterTestCase.php +++ b/tests/Authentication/Filters/AbstractFilterTestCase.php @@ -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']); diff --git a/tests/Authentication/Filters/SessionFilterTest.php b/tests/Authentication/Filters/SessionFilterTest.php index 1b379ccc3..a217d7a74 100644 --- a/tests/Authentication/Filters/SessionFilterTest.php +++ b/tests/Authentication/Filters/SessionFilterTest.php @@ -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]); @@ -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());