Joan Gavelán
AEAsh Elixir
•Created by Joan Gavelán on 5/10/2025 in #support
Guidance on Dynamic Filtering, Sorting, and Pagination
Hello Ash community,
I'm implementing standard filtering, sorting, and pagination features for my contacts module and have defined a read action as follows:
In my controller, I parse incoming parameters with default values:
I invoke the function as:
I'd like to understand how to pass these parameters to effectively filter, sort, and paginate the contacts list. Specifically:
- How can I apply a case-insensitive search filter to multiple attributes and only when search_query is present?
- What's the recommended way to implement dynamic sorting based on sort_by and sort_dir?
- How should I handle pagination using current_page?
- Are there best practices for sanitizing and validating these parameters before applying them?
Any guidance or examples on implementing these features would be greatly appreciated.
Thanks in advance!
19 replies
AEAsh Elixir
•Created by Joan Gavelán on 5/2/2025 in #support
Custom Authentication Flow with AshAuthentication in Phoenix + React (Inertia.js)
Hi everyone! I've been implementing a custom authentication flow using AshAuthentication with Phoenix and React via Inertia.js. I wanted to share my approach and ask for feedback, especially regarding password reset functionality.
Working Authentication Actions
So far, I've successfully implemented the following actions defined by the AshAuthentication generator in my User Resource:
Registration Controller
Here's how I'm handling registration:
Login Controller
And here's the login implementation:
Password Reset Flow
I've implemented the first part of the password reset flow - requesting a reset token:
Issue with Password Reset
I'm trying to implement the controller to update the password, but I'm getting an error:
The error I'm getting is:
It seems like there's an issue with a "primary key", but I'm not sure what this means since I am passing all the expected parameters (password, password_confirmation, token).
So, how should I properly implement this?
Thanks in advance for any help or insights!
17 replies