-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Craft Auth scaffolding, remove registration #754
Comments
@funkywaddle In the mean time did you figure out how to disable the registration routes? I'm coming from the Laravel world and this is something I need here as well. This is defiantly a messy hack but I made my routes file look like this: from masonite.routes import Route
from masonite.authentication import Auth
ROUTES = [Route.get("/", "WelcomeController@show")]
ROUTES += Auth.routes()
for route in ROUTES:
if route.controller == 'auth.RegisterController@show':
ROUTES.remove(route)
for route in ROUTES:
if route.controller == 'auth.RegisterController@store':
ROUTES.remove(route) And the output of routes list: python3 craft routes:list
+-------------------------+-----------------------+-----------+-----------------------------------------------------+---------------+
| URI | Name | Method(s) | Controller | Middleware(s) |
+-------------------------+-----------------------+-----------+-----------------------------------------------------+---------------+
| / | | GET/HEAD | WelcomeController@show | web |
| /_exceptionite/actions | | POST | ExceptioniteController@run_action | |
| /change_password/@token | change_password | GET/HEAD | auth.PasswordResetController@change_password | web |
| /change_password/@token | change_password.store | POST | auth.PasswordResetController@store_changed_password | web |
| /home | auth.home | GET/HEAD | auth.HomeController@show | web,auth |
| /login | login | GET/HEAD | auth.LoginController@show | web |
| /login | login.store | POST | auth.LoginController@store | web |
| /logout | logout | GET/HEAD | auth.LoginController@logout | web |
| /password_reset | password_reset | GET/HEAD | auth.PasswordResetController@show | web |
| /password_reset | password_reset.store | POST | auth.PasswordResetController@store | web |
+-------------------------+-----------------------+-----------+-----------------------------------------------------+---------------+ So it seems to have removed the route but it defiantly is not efficient to run two for loops on the routes array to pull this off. There has to be a better way. |
I come from the Land of Laravel myself, @MelonSmasher . That's one reason why I love this framework. It is so reminiscent/similar to how Laravel does things, and the directory structure, I feel at home. As far as how to disable the registration routing, your way works. Another way I found was to remove the call to It's a more manual approach to yours, but I think slightly more concrete as it doesn't rely on matching strings. Just a pure copy/paste of needed routes. |
@funkywaddle I like your way much better. Thank you! |
Yes, customizing auth routes and/or the registration controller can all be done manually in your code base. |
Is your feature request related to a problem?
I would like to have login, logout, password reset, etc functionality, but ability to remove registration for sites that I don't want registration open to the world.
What do we currently have to do now?
Not sure how to remove registration functionality.
Describe the solution you'd like
provide options to craft cli to scaffold the auth, but not include registration.
This may require a create-user command to create a registered user since registration would be turned off, that asks for email, username, password, etc
Describe alternatives you've considered
Alternatively, provide a way to turn off registration via configuration, so:
Would this be a breaking change ?
Anything else ?
No response
The text was updated successfully, but these errors were encountered: