Stormlight
Stormlight
Explore posts from servers
BABetter Auth
Created by Stormlight on 3/25/2025 in #help
How to implement invite-only registration flow with better-auth?
Hello, I'm looking for some help on how to implement this use-case. Here is the general user creation/registration flow I want to implement:
1. Existing admin user adds a new user by entering their email (and possibly name and role). 2. The new user receives email with a welcome message and a link (time limited) to complete account setup. 3. After clicking the link, the user is redirected to a page where they can enter a password and/or link their social account. 4. User is redirected to the app's main page. 5. Future logins for the user will be done using their password or social account.
I've tried using magic links, but I got stuck on how to then add a credentials account to the user. Magic link also doesn't handle the user's role, but I can manage with setting it up later. Here is another alternative I've considered, and I'd appreciate some feedback on whether it should work and if it's a good way to do that. Use the admin API to add users and then send them a "forgot password" link with a custom message. This will then redirect them to reset the password. Any thoughts?
8 replies
RRefine
Created by plain-purple on 2/12/2025 in #ask-any-question
Apply form to multiple parent ids
I have an api where I have a list of some items, and each item has other sublists, in this case some controls. I need to create a form that shows the controls data for a selected item, and when the user clicks apply it opens a dialog that shows the changes, and most importantly it should have the option to select which items to apply the changes to (current item will be selected by default). How can I achieve that? I'm using Ant Design for ui.
5 replies
RRefine
Created by sensitive-blue on 1/19/2025 in #ask-any-question
Pulling data from hierarchical api
I have an api that exposes multiple endpoints that are hierarchical in nature. For example: /container - returns a list with minimal data like id and name /container/types - returns a list of types /container/types/type - returns a list of items that belong to each type container/types/type/id - returns a specific item I need to build a form that will contain all of the specific items, or possibly a form for each one. What is the correct way to achieve this?
10 replies
RRefine
Created by passive-yellow on 1/14/2025 in #ask-any-question
Sub menu with own page
using ant-design... Is there a way to add a menu item that both acts as a parent to other resources, and is also selectable by iteself? For example: Storage (top level menu item, when clicked opens a page and also expands the sub-menu). Storage>settings Storage>export
10 replies
RRefine
Created by exotic-emerald on 1/12/2025 in #ask-any-question
Modal form unsaved changes prompt settings
I'm using Ant Design, and I'm trying to set up a form that will be displayed within a Modal. I'm using useModalForm and everything works great, except for one thing. When I make any change and then try to close the form without saving, it shows the unsaved changes warning. However, when I then click cancel on the warning prompt, it then closes the form and Modal and goes back to the parent "list" page. And if I click OK instead (which should close the form), it keeps the form open and reverts my changes. I'm using this code-snippet from one of the examples (finefoods-antd):
const onModalClose = () => {
close();
go({
to:
searchParams.get("to") ??
getToPath({
action: "list",
}) ??
"",
query: {
to: undefined,
},
options: {
keepQuery: true,
},
type: "replace",
});
};
const onModalClose = () => {
close();
go({
to:
searchParams.get("to") ??
getToPath({
action: "list",
}) ??
"",
query: {
to: undefined,
},
options: {
keepQuery: true,
},
type: "replace",
});
};
I'm then using it in the Modal props for onCancel. I've tried using it as onClose instead, but then the modal just stays open. I assume that somehow this setting is passed to the unsaved-changes prompt, which then applies that when I hit cancel, instead of keeping the form open with the changes intact. Am I doing something wrong, or is this an expected behavior? Note that in the finefoods-antD example, the behavior is similar and does not persist changes.
13 replies
RRefine
Created by other-emerald on 1/9/2025 in #ask-any-question
modify dataProvider update to support nested endpoint with multiple ids
I'm trying to modify the simple-rest dataProvider so that I can send requests to endpoints that require more than one id. For example, I have some container entity that I need to list, and then this entity has some items that I want to edit using a form. However, the methods should be able to support either case. For example: Endpoint 1 - /api/scheduler/id - supports GET and POST Endpoint 2 - /api/container/id - supports GET Endpoint 3/ /api/container/id/item-id - supports GET and POST note that I'm using POST for updates. The easiest way seems to be to add another parameter to the update method, but that doesn't work since "Property 'itemId' does not exist on type 'UpdateParams<TVariables>'". What's the correct way to handle that?
27 replies
RRefine
Created by adverse-sapphire on 12/31/2024 in #ask-any-question
Implementing oidc authProvider for Authelia with react-oidc-context
I'm trying to add Authelia as an auth provider to my project. I'm currently trying to use the example for Keycloak from github to help me with the basic setup. I'm currently a bit confused as to how to integrate it. Authelia has its own login pages, and it requires a redirect url. I'm not sure which url that should be. In addition, I need to add some custom logic that will happen when logging in or out. I'm pulling data from Grafana based on the logged in user, and I need to initialize the grafana session so that the api calls will be authenticated correctly. What is the recommended approach for this scenario?
10 replies
RRefine
Created by metropolitan-bronze on 12/29/2024 in #ask-any-question
useTable with complex response
Hello, first time here, and first project with refine! I'm trying to get some data from an api (prometheus alertmanager), and I ran into some issues. I can get the data from the API, but my problem is with parsing it correctly. I couldn't find how to either - 1) map the values into a different simple structure (e.g., map fingerprint to id, labels.* to * and so on), or 2) specifiy dataIndex in <Table.Column> props so that it reads the nested values. An example response can look like this: { "annotations": { "description": "Disk usage is more than 80%\n VALUE = 81.5100154083205\n LABELS = map[instance:some-ip:port job:win_env site:site-name volume:volume-name]", "summary": "Windows Server disk Space Usage (instance some-ip:port)" }, "endsAt": "2024-12-29T12:12:04.162Z", "fingerprint": "3cf84c3fb282409f", "receivers": [ { "name": "mail" } ], "startsAt": "2024-12-25T06:36:04.162Z", "status": { "inhibitedBy": [], "silencedBy": [], "state": "active" }, "updatedAt": "2024-12-29T12:08:04.159Z", "generatorURL": "generator_url/graph?g0.expr=80+%3C+%28100+-+100+%2A+%28%28windows_logical_disk_free_bytes+%2F+1024+%2F+1024%29+%2F+%28windows_logical_disk_size_bytes+%2F+1024+%2F+1024%29%29%29+%3C+85&g0.tab=1", "labels": { "alertname": "WindowsServerDiskSpaceUsage", "instance": "some-ip:port", "job": "win_env", "severity": "minor", "site": "site-name", "volume": "volume-name" } } Additional info: Using Vite, AntD, custom auth (currently none).
20 replies