Stormlight
Explore posts from serversBABetter Auth
•Created by Stormlight on 3/25/2025 in #help
How to implement invite-only registration flow with better-auth?
In my setup I've disabled the sign-up endpoint, which is enabled by default. i.e, anyone can send post request to the endpoint, unless you change it somehow.
I've also disable the sign-up option for social login.
This setup ensures that only admin user can add users, both from ui and api.
8 replies
BABetter Auth
•Created by Stormlight on 3/25/2025 in #help
How to implement invite-only registration flow with better-auth?
Correct.
On the client side (UI) I have an admin page for creating a user. I enter email, name and role and submit.
In handle submit I first create the user using
authClient.admin.createUser
and I use generateRandomString
from better-auth/crypto
to generate a password (which I don't show or save anywhere).
Then I use the forgotPassword with redirectTo: "/complete-registration"
.
On the server I've set sendResetPassword
option with a check on the callbackURL
, so I send a different message if it's first login or if the user actually clicked forgot password by themselves. And of course create the relevant pages on the frontend.
It's working fine for now, but I'll gladly switch to a dedicated solution when it's available.8 replies
BABetter Auth
•Created by AB on 3/28/2025 in #help
Single Auth Multiple apps setup.
I'm only using the server side atm so didn't try the generic OAuth client, but I've set up Grafana with my server without issues
39 replies
BABetter Auth
•Created by AB on 3/28/2025 in #help
Single Auth Multiple apps setup.
Oh sorry... After reading the documentation again I see I was wrong about using the client plugin. It's meant to be used to expose the register endpoint via ui.
I believe you need to do the following:
Set your server as oidc provider using the plugin, then use the register endpoint to generate a new client (via curl/postman or similar).
Add the generic OAuth plugin to both server and client. Use the client ID and secret to set the server plugin.
Then, use the generic OAuth client plugin to authenticate.
39 replies
BABetter Auth
•Created by AB on 3/28/2025 in #help
Single Auth Multiple apps setup.
Did you set up your server as oidcProvider? It doesn't show in the code example above.
And you can use oidcClient instead of generic OAuth
https://www.better-auth.com/docs/plugins/oidc-provider
39 replies
BABetter Auth
•Created by Stormlight on 3/25/2025 in #help
How to implement invite-only registration flow with better-auth?
Oh nice! Thanks for taking the time to reply.
I've managed to implement it with the forgot password for now, but having it built in will be amazing!
8 replies
BABetter Auth
•Created by je823 on 3/25/2025 in #help
creating the first user, where disableSignUp is true
You can use the db adapter to seed the database with the admin user.
I'm using drizzle-orm and I've created a seed.ts file, which I then ran using
"bun run server/src/db/seed.ts"
.
If you use a different adapter then you'll need to check their docs on seeding the database.
Here is the script:
3 replies
RRefine
•Created by like-gold on 1/19/2025 in #ask-any-question
Pulling data from hierarchical api
@kapa.ai please explain how this part works
Once I get the types, I'm currently trying to do
This results in the error
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
10 replies
RRefine
•Created by unwilling-turquoise on 1/14/2025 in #ask-any-question
Sub menu with own page
@kapa.ai if I want to use more icons than are available with ant design, what would be the best approach? downloading specific icons and adding them to my project, or maybe installing the mui support and use mdi icons?
10 replies
RRefine
•Created by vicious-gold on 1/12/2025 in #ask-any-question
Modal form unsaved changes prompt settings
@kapa.ai formState does not exist. Any other suggestion?
13 replies
RRefine
•Created by funny-blue on 1/12/2025 in #ask-any-question
Modal form unsaved changes prompt settings
@kapa.ai is there a simple way (like a hook) to check if there are unsaved changes myself?
13 replies
Hello, I've recently started working
Thanks for the response!
I've managed to get it working for the most part, though I still have some issues with it.
I'm currently using a callback component that shows loading screen and performs some background process. The react-oidc-context (with oidc-client-ts) is supposed to handle the rest. The main issue I currently have is that for some reason the session-storage seems to reset when I refresh the page, and so it always redirects back to homepage (it actually goes to /login and then immediately to /). Hopefully I'll be able to solve this soon.
It would be really amazing if refine will support react-oidc-context as AuthProvider for generic oidc. It should allow working with any provider. For example, the keycloak packages used by refine are deprecated for years now and recommend using react-oidc-context.
I wish I had the knowledge and time to implement it myself 😔
2 replies
RRefine
•Created by adverse-sapphire on 1/2/2025 in #ask-any-question
Hello everyone,
It's supported.. the ai thought you're asking if it supports older version.
https://refine.dev/docs/data/data-provider/#supported-data-providers
6 replies
RRefine
•Created by correct-apricot on 1/9/2025 in #ask-any-question
modify dataProvider update to support nested endpoint with multiple ids
@kapa.ai I do have this option set to true. What might interfere with that?
27 replies
RRefine
•Created by extended-salmon on 1/9/2025 in #ask-any-question
modify dataProvider update to support nested endpoint with multiple ids
@kapa.ai Another unrelated question... when I refresh the page, currently it always go to my home page. In the fine-foods-antd example, when I refresh the page it goes back to what it was before (in most cases).
How can this be done?
27 replies
RRefine
•Created by graceful-blue on 1/9/2025 in #ask-any-question
modify dataProvider update to support nested endpoint with multiple ids
@kapa.ai adjust the answer for antD
27 replies
RRefine
•Created by passive-yellow on 1/9/2025 in #ask-any-question
modify dataProvider update to support nested endpoint with multiple ids
@kapa.ai
I see. Now, let's say that the /api/container endpoint returns a list of all the items. I then want to create a form that will list all the items (most of them are switches), and instead of having a save button, it should handle changes directly and update individual items using the item endpoint.
For switches/toggles it should open a confirmation warning dialog immediately on change. If it's a text/number input, then the item should have some button to apply the change (as I don't want it to update on every tick).
What's the correct approach to do that?
I'm using useModalForm for initiating and displaying the form.
27 replies
RRefine
•Created by genetic-orange on 1/6/2025 in #ask-any-question
Claude or similar AI agents for building Refine projects
I'm personally using cursor. It's doing a pretty good job, depends on the complexity of what you are trying to achieve. It can definitely be a time saver if you know what you are doing, but it's not perfect if you are trying to learn and use best practices.
11 replies
RRefine
•Created by genetic-orange on 12/31/2024 in #ask-any-question
Implementing oidc authProvider for Authelia with react-oidc-context
@kapa.ai I currently have an issue where the <Authenticated> element never changes to true, even though the useAuth hook from react-oidc-context returns isAuthenticated true.
When I look at the refine devtools, I see one call to useIsAuthenticated, and one to useGetIdentity. I don't see any return values for the queries.
What might be causing this?
Here is my "check" code:
check: async () => {
console.log("Checking auth...");
while (auth.isLoading) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
try {
console.log("user", auth.user);
if (auth.user?.access_token) {
return {
authenticated: true,
};
}
return {
authenticated: false,
logout: true,
redirectTo: "/login",
error: {
message: "Check failed",
name: "Token not found",
},
};
}
10 replies