Skip to content

feat: using a more precise return #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
@@ -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();
29 changes: 29 additions & 0 deletions tests/Controllers/RegisterTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.70s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccess

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.69s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredAndSessionExpiredAndLogin

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.69s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndLogin

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.68s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccessWithNoEmailLogin

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.67s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndRegisterAgain

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.67s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionWithBadEmailValue

Check warning on line 1 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.66s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterRedirectsToActionIfDefined

declare(strict_types=1);

@@ -53,7 +53,7 @@
Factories::injectMock('config', 'Validation', $config);
}

public function testRegisterActionSuccess(): void

Check warning on line 56 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.65s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccess

Check warning on line 56 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.53s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccess

Check warning on line 56 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.61s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccess

Check warning on line 56 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.69s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccess
{
$result = $this->withSession()->post('/register', [
'username' => 'JohnDoe',
@@ -91,7 +91,7 @@
$this->assertTrue($user->active);
}

public function testRegisterActionSuccessWithNoEmailLogin(): void

Check warning on line 94 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.65s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccessWithNoEmailLogin

Check warning on line 94 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.54s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccessWithNoEmailLogin

Check warning on line 94 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.60s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccessWithNoEmailLogin

Check warning on line 94 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.71s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionSuccessWithNoEmailLogin
{
/** @var Auth $config */
$config = config('Auth');
@@ -183,7 +183,7 @@
$this->assertCount(4, session('errors'));
}

public function testRegisterRedirectsToActionIfDefined(): void

Check warning on line 186 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.66s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterRedirectsToActionIfDefined

Check warning on line 186 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.54s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterRedirectsToActionIfDefined

Check warning on line 186 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.61s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterRedirectsToActionIfDefined

Check warning on line 186 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.68s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterRedirectsToActionIfDefined
{
// Ensure our action is defined
$config = config('Auth');
@@ -207,7 +207,7 @@
]);
}

public function testRegisteredButNotActivatedAndLogin(): void

Check warning on line 210 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.65s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndLogin

Check warning on line 210 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.52s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndLogin

Check warning on line 210 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.61s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndLogin

Check warning on line 210 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.70s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndLogin
{
// Ensure our action is defined
$config = config('Auth');
@@ -231,7 +231,7 @@
$result->assertRedirectTo('/auth/a/show');
}

public function testRegisteredButNotActivatedAndRegisterAgain(): void

Check warning on line 234 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.65s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndRegisterAgain

Check warning on line 234 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.51s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndRegisterAgain

Check warning on line 234 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.62s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndRegisterAgain

Check warning on line 234 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.69s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredButNotActivatedAndRegisterAgain
{
// Ensure our action is defined
$config = config('Auth');
@@ -257,7 +257,7 @@
$result->assertRedirectTo('/auth/a/show');
}

public function testRegisteredAndSessionExpiredAndLogin(): void

Check warning on line 260 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.65s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredAndSessionExpiredAndLogin

Check warning on line 260 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.54s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredAndSessionExpiredAndLogin

Check warning on line 260 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.61s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredAndSessionExpiredAndLogin

Check warning on line 260 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.70s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisteredAndSessionExpiredAndLogin
{
// Ensure our action is defined
$config = config('Auth');
@@ -313,7 +313,7 @@
$result->assertRedirectTo(config('Auth')->registerRedirect());
}

public function testRegisterActionWithBadEmailValue(): void

Check warning on line 316 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.63s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionWithBadEmailValue

Check warning on line 316 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.51s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionWithBadEmailValue

Check warning on line 316 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.59s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionWithBadEmailValue

Check warning on line 316 in tests/Controllers/RegisterTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.66s from 0.50s limit to run Tests\\Controllers\\RegisterTest::testRegisterActionWithBadEmailValue
{
$result = $this->withSession()->post('/register', [
'username' => 'JohnDoe',
@@ -331,6 +331,35 @@
);
}

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' => 'foo@example.com',
'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');

Unchanged files with check annotations Beta

<?php

Check warning on line 1 in tests/Unit/UserIdentityModelTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.70s from 0.50s limit to run Tests\\Unit\\UserIdentityModelTest::testForceMultiplePasswordReset
declare(strict_types=1);
);
}
public function testForceMultiplePasswordReset(): void

Check warning on line 86 in tests/Unit/UserIdentityModelTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.71s from 0.50s limit to run Tests\\Unit\\UserIdentityModelTest::testForceMultiplePasswordReset

Check warning on line 86 in tests/Unit/UserIdentityModelTest.php

GitHub Actions / phpunit / PHP 8.0 - SQLite3

Took 0.69s from 0.50s limit to run Tests\\Unit\\UserIdentityModelTest::testForceMultiplePasswordReset

Check warning on line 86 in tests/Unit/UserIdentityModelTest.php

GitHub Actions / phpunit / PHP 8.0 - MySQLi

Took 0.81s from 0.50s limit to run Tests\\Unit\\UserIdentityModelTest::testForceMultiplePasswordReset

Check warning on line 86 in tests/Unit/UserIdentityModelTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.78s from 0.50s limit to run Tests\\Unit\\UserIdentityModelTest::testForceMultiplePasswordReset
{
/** @var Fabricator $fabricator */
$fabricator = new Fabricator(UserIdentityModel::class);
<?php

Check warning on line 1 in tests/Unit/DictionaryValidatorTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.55s from 0.50s limit to run Tests\\Unit\\DictionaryValidatorTest::testCheckTrueOnNotFound
declare(strict_types=1);
$this->assertFalse($result->isOK());
}
public function testCheckTrueOnNotFound(): void

Check warning on line 45 in tests/Unit/DictionaryValidatorTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.54s from 0.50s limit to run Tests\\Unit\\DictionaryValidatorTest::testCheckTrueOnNotFound

Check warning on line 45 in tests/Unit/DictionaryValidatorTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.51s from 0.50s limit to run Tests\\Unit\\DictionaryValidatorTest::testCheckTrueOnNotFound
{
$password = '!!!gerard!!!abootylicious';
<?php

Check warning on line 1 in tests/Unit/PasswordsTest.php

GitHub Actions / phpunit / PHP 7.4 - MySQLi - lowest

Took 0.55s from 0.50s limit to run Tests\\Unit\\PasswordsTest::testHash
declare(strict_types=1);
$this->assertSame('A Password is required.', $result->reason());
}
public function testHash(): string

Check warning on line 36 in tests/Unit/PasswordsTest.php

GitHub Actions / phpunit / PHP 7.4 - Postgre

Took 0.55s from 0.50s limit to run Tests\\Unit\\PasswordsTest::testHash

Check warning on line 36 in tests/Unit/PasswordsTest.php

GitHub Actions / phpunit / PHP 8.2 - MySQLi

Took 0.53s from 0.50s limit to run Tests\\Unit\\PasswordsTest::testHash
{
$config = new AuthConfig();
$passwords = new Passwords($config);