Did anything come of the additional struct for user connection variables:
%MyApp.Scope{
user: ...,
org: ....,
user_agent: ...,
client_ip: ...,
}
from Chris McCord’s ElixirConf 2023 Field Notes
@ 05:07?
Did anything come of the additional struct for user connection variables:
%MyApp.Scope{
user: ...,
org: ....,
user_agent: ...,
client_ip: ...,
}
from Chris McCord’s ElixirConf 2023 Field Notes
@ 05:07?
Good question! I’m guessing it’s going to show up in 1.8 in phx_new. It’s really just a pattern and doesn’t require anything other than creating the module and using it so maybe it’ll just show up in the docs? It’s one of those things that can be confusing to those who don’t need it, prone to abuse by those who don’t understand why they would want it but use it anyway, and already in use by many people. I can see it not being a huge priority/rolled out carefully.
is this just something like a struct defined at lib/my_app/scope.ex
that gets loaded/injected to assigns via a plug?
I’m asking because I actually will need to do this soon myself and so I’m curious about it. Also, there’s been no mention in the repo of this in my quick searching
You can look at TodoTrek for its usage of Scope: todo_trek/lib/todo_trek/scope.ex at main · chrismccord/todo_trek · GitHub
Ahh , great, thank you! I recall that being mentioned but couldn’t catch the full reference.
We already use a similar %{user_id: …, scope_id: …, …} in a manner very much as described by @chrismccord for managing authorisation/metadata for commanded/commanded commands.
So just interested to have the approach validated and to compare how it’s being used …
Thanks again …