require authenticated user
Hi,Im still new to elixir and phoenix.
I'm using ash_authentication_phoenix.
i want to redirect user after sign-in to "/dashboard" and prevent unsigned user from the route.
I read the doc but I cant figure it.
14 Replies
in ash_hq we use this:
And then we do this kind of thing:
This is what you'd do for liveviews
For regular views/controllers you'd use a plug.
Thanks you so much.it work..I did not aware ash-hq web on github.
Yep! That can be a great place to look for example code.
As an aside here Zach, might be worth compiling a few example repos into a guide on the Ash primary repo docs folder, between real world, twitter, and ash hq you can usually find what you need.
Good point. We have a link to repos (not including realworld because that is new) in the Media page, but adding them to the sidebar would be cool
I copy code from
finally I remove the
ash_hq
and it doesn't load current user
then I replace live_session
with ash_authentication_live_session
and I got this compile errorfinally I remove the
:session
options and it works
🤔
Ah, yeah, that is a bug
but your solution is correct
There apparently has to be only one session hook
I think we should add this to
AshAuthentication.Phoenix
tutorialDoes it not show using
ash_authentication_live_session
in that tutorial?
Can you show me where its missing? Happy to fixNo I cannot find in the tutorial
I will add a liveview specific tutorial and link to it from the end of the getting started guide 😄
GitHub
ash_authentication_phoenix/use-ash-authentication-with-liveview.md ...
Drop-in authentication support for Phoenix apps using AshAuthentication. - ash_authentication_phoenix/use-ash-authentication-with-liveview.md at main · team-alembic/ash_authentication_phoenix
This will be on ash HQ in the next release
That's great, thank you