Add abililiy to disable user Registration #295

Closed
opened 2026-03-13 07:41:03 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @daddasoft on GitHub (Nov 28, 2024).

Is your feature request related to a problem? Please describe.

Add abililiy to disable user Registration on internal use app so only admin create accounts

Originally created by @daddasoft on GitHub (Nov 28, 2024). **Is your feature request related to a problem? Please describe.** Add abililiy to disable user Registration on internal use app so only admin create accounts
Author
Owner

@avanderbergh commented on GitHub (Nov 28, 2024):

Am I missing something? better-auth gives you the tools to implement user registration, but it doesn't mean you have to do it...

You can simply choose not to implement it... 😅

@avanderbergh commented on GitHub (Nov 28, 2024): Am I missing something? `better-auth` gives you the tools to implement user registration, but it doesn't mean you have to do it... You can simply choose not to implement it... 😅
Author
Owner

@daddasoft commented on GitHub (Nov 28, 2024):

no i didnt mean that i mean like if some one now im using better auth and try to create a user by the api not the code part

@daddasoft commented on GitHub (Nov 28, 2024): no i didnt mean that i mean like if some one now im using better auth and try to create a user by the api not the code part
Author
Owner

@daddasoft commented on GitHub (Nov 28, 2024):

image

@daddasoft commented on GitHub (Nov 28, 2024): ![image](https://github.com/user-attachments/assets/0a9e40a3-b7ad-4710-9f74-abea2550e096)
Author
Owner

@daddasoft commented on GitHub (Nov 28, 2024):

in this case i didnt have a register page but i create it just by api

@daddasoft commented on GitHub (Nov 28, 2024): in this case i didnt have a register page but i create it just by api
Author
Owner

@avanderbergh commented on GitHub (Nov 28, 2024):

in this case i didnt have a register page but i create it just by api

Ah, I see... So the sign-up endpoint is always created.

It might be good to have an option on the emailAndPassword to disallow sign-ups.

In the meantime, there might be a workaround...

I see there is a databaseHooks prop on BetterAuthOptions which allows you to define custom hooks that can be executed during lifecycle of core database operations.

So, you could add some code to the user.before hook that simply returns false. Or do something like only allowing email from a certain domain. Or checking an invite table to something else...

@avanderbergh commented on GitHub (Nov 28, 2024): > in this case i didnt have a register page but i create it just by api Ah, I see... So the `sign-up` endpoint is always created. It might be good to have an option on the `emailAndPassword` to disallow sign-ups. In the meantime, there might be a workaround... I see there is a `databaseHooks` prop on [`BetterAuthOptions`](https://www.better-auth.com/docs/reference/options) which allows you to define custom hooks that can be executed during lifecycle of core database operations. So, you could add some code to the `user.before` hook that simply returns `false`. Or do something like only allowing email from a certain domain. Or checking an `invite` table to something else...
Author
Owner

@daddasoft commented on GitHub (Nov 28, 2024):

good thanks a lot

but a boolean toggle in wort it and easy

@daddasoft commented on GitHub (Nov 28, 2024): good thanks a lot but a boolean toggle in wort it and easy
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#295