-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: Disable Signups for new users #7254
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the work.
However it is a little bit more complicated than needed, please see my reviews.
phpunit.xml
Outdated
@@ -8,6 +8,7 @@ | |||
<testsuite name="Unit"> | |||
<directory suffix="Test.php">./tests/Feature</directory> | |||
<directory suffix="Test.php">./tests/Unit</directory> | |||
<directory suffix="Test.php">./tests/PHPUnit</directory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't create another testsuite. Those tests should be placed under Unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asbiin, Unit tests in Laravel are not a classic pure unit test, because they bootstrap the kernel, database, and much more. A pure unit test only works with abstractions and does not depend on anything, for this reason it is cleaner and faster. I can move the tests to the unit folder, but I would still suggest separating test types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asbiin, change reverted
use Tests\TestCase; | ||
|
||
class RegistrationTest extends TestCase | ||
{ | ||
use DatabaseTransactions; | ||
|
||
#[Test] | ||
public function registration_screen_can_be_rendered() | ||
public function testAccessToRegistrationPage(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing #[Test]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asbiin, it is enough that the name of the method begins with the word “test” and the phpunit recognizes it as a test method. The attribute is not needed here. see https://docs.phpunit.de/en/11.1/attributes.html#test
protected function patchRoutes(): void | ||
{ | ||
if ($this->app->routesAreCached()) { | ||
return; | ||
} | ||
|
||
$router = $this->app->make(Router::class); | ||
$routes = $router->getRoutes(); | ||
collect(['create', 'store'])->each(function ($method) use ($routes) { | ||
if ($route = $routes->getByAction(RegisteredUserController::class . '@' . $method)) { | ||
$route->middleware('monica.signup_is_enabled'); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go directly in the routes/web.php
file, there is no need to "patch" the route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asbiin, no, it shouldn't be in the routes/web.php
.
Routes and controller are part of the fortify
package. I don’t want to redefine the entire route, we just need to add our custom middleware, that’s why we alter the routes in the service provider.
Co-authored-by: Alexis Saettler <alexis@saettler.org>
Co-authored-by: Alexis Saettler <alexis@saettler.org>
Co-authored-by: Alexis Saettler <alexis@saettler.org>
Co-authored-by: Alexis Saettler <alexis@saettler.org>
These changes allow to enable/disable new user registration based on ENV setting. The feature was implemented in version 4.x and was not present in chandler. Fixes #6687
Changes:
APP_DISABLE_SIGNUP