Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addict.Helpers.current_user can grow stale #112

Open
eteeselink opened this issue Oct 18, 2016 · 0 comments
Open

Addict.Helpers.current_user can grow stale #112

eteeselink opened this issue Oct 18, 2016 · 0 comments

Comments

@eteeselink
Copy link

Hey there!

I'm not sure if this is a bug, a feature request, or simply a bad idea but I've noticed that the user object is stored in the Phoenix session once on login and then never updated.

I solved it for my particular case by making a refresh_user helper and calling it in the appropriate controller functions:

  defp refresh_user(conn) do
    stale_user = Addict.Helper.current_user conn
    {:ok, user} = Addict.Interactors.GetUserById.call stale_user.id
    {:ok, conn} = Addict.Interactors.CreateSession.call conn, user
    conn
  end

I reused some nice helper functions from Addict, not sure the Interactors were supposed to be used this way. Is this an approach that you'd support? Would it be useful to add this to Addict.Helper maybe? If so, I'll happily make a PR.

Or did I totally not understand something and shouldn't I be wanting to refresh the user hash in the session?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant