janko / rodauth-rails

Rails integration for Rodauth authentication framework
https://github.com/jeremyevans/rodauth
MIT License
571 stars 40 forks source link

Disable User Creation #86

Closed delCatta closed 2 years ago

delCatta commented 2 years ago

I would like to know how I can disable Account Creation.

I need this because I have one admin account that could create accounts.

Removing :create_account from the enable in rodauth_main.rb doen't seem to work...

janko commented 2 years ago

You'll need to disable verify_account and verify_account_grace_period features too, as those depend on the create_account feature, so they pull it in automatically.

brunoprietog commented 2 years ago

Isn't there a way to disable some routes? For example, make /create-account path not available. If you disable the feature, you cannot use it with internal_request in other parts of the application

brunoprietog commented 2 years ago

I discovered that you can set the value of a rodauth route configuration to nil, for example:

create_account_route nil

This causes the rodauth router to ignore it and pass it to the Rails router, allowing you to easily handle the error

janko commented 2 years ago

@brunoprietog I thought I knew everything there is to know about Rodauth, but you just taught me something new 🙂 This works because, when nil is passed to r.is, it doesn't match. BTW, I think showing this would be a useful addition to the Change route path official guide 😉

@delCatta Since the question was answered, I'm closing this one. In the future please use GitHub Discussions for usage questions 🙂