Skip to content
Open
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
4 changes: 1 addition & 3 deletions src/Authentication/Actions/EmailActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ public function verify(IncomingRequest $request)

// No match - let them try again.
if (! $authenticator->checkAction($identity, $postedToken)) {
session()->setFlashdata('error', lang('Auth.invalidActivateToken'));

return $this->view(setting('Auth.views')['action_email_activate_show']);
return redirect()->back()->with('error', lang('Auth.invalidActivateToken'));
}

$user = $authenticator->getUser();
Expand Down
29 changes: 29 additions & 0 deletions tests/Controllers/RegisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,35 @@ public function testRegisterActionWithBadEmailValue(): void
);
}

public function testRegisterActionRedirectsIfTokenNotMatch(): void
{
// Ensure our action is defined
$config = config('Auth');
$config->actions['register'] = EmailActivator::class;
Factories::injectMock('config', 'Auth', $config);

// Already registered but not yet activated and logged in.
$result = $this->post('/register', [
'email' => '[email protected]',
'username' => 'foo',
'password' => 'abkdhflkjsdflkjasd;lkjf',
'password_confirm' => 'abkdhflkjsdflkjasd;lkjf',
]);

// Should have been redirected to the action's page.
$result->assertRedirectTo('/auth/a/show');

// Attempted to send an invalid token.
$result = $this->withSession()->post('/auth/a/verify', [
'token' => 'invalid-token',
]);

// Should have been redirected to the previous page.
$result->assertStatus(302);
$result->assertRedirect();
$result->assertSee(lang('Auth.invalidActivateToken'));
}

protected function setupConfig(): void
{
$config = config('Validation');
Expand Down