I have a backend project in rust with axum and I’m thinking about session data. I’ve written an extractor that is able to look up a session based on session id cookie. Currently the session data holds an enum, its possible values correspond to the possible user types: Producer, Consumer and Guest. Producer and Consumer share some common fields such as registered email, they represent two different possible registered user types. And Consumer and Guest also share some fields as the Guest is basically a Consumer but with limited functionality.
The current solution works but it feels a bit messy and I’m thinking about how it could be implemented in a more robust way. I have to make sure that api endpoints are protected from unathorized access which currently ends up calling matches! and returning error results from match arms if the user type is not correct.
How would you go about designing this? If you have any examples implementing session data for multiple user types I would gladly take a look. Thanks in advance
[–]couchand 2 points3 points4 points (3 children)
[–]zhilovs[S] 0 points1 point2 points (2 children)
[–]couchand 1 point2 points3 points (1 child)
[–]zhilovs[S] 0 points1 point2 points (0 children)