Daniel4lm

Daniel4lm

Preserve params between pages

Hii everyone. Fairly new to Elixir/Phoenix

Phoenix App contains 2 live pages, openings_live and job_application and uses github Uberauth for auth.
openings_live serves as landing page with list of positions with buttons where user can login to GitHub,
job_application is a form where user can apply to desire position.

In router I serve something like this:

scope "/", LandingWeb do
    pipe_through :browser
    ...
    # landing page main route
    live "/", JobLive.OpeningsLive.Index, :index
  end

# github auth scope
  scope "/auth", LandingWeb do
    pipe_through :browser
    ...
    # job application route - protected
    live_session :default, on_mount: LandingWeb.UserAuthLive do
      live "/job_openings/:id/apply", JobApplicationFormLive, :index
    end

    # github auth routes
    get "/:provider", GithubAuthController, :request
    get "/:provider/callback", GithubAuthController, :callback
  end

After user clicks on the login button on landing page it takes them to the GitHub page and use their profile data.
When GitHub returns the user to the landing page, it should take the user to job_application form.

The question is, how I can preserve, between page reloads, job_id from openings_live so I can use it in job_application form ? I could use session for temporary storing job_id and read it in mount() fun.

Is there better solution for this?

Thanks!
Daniel

Most Liked

kokolegorille

kokolegorille

Hello and welcome, I reformatted the post to be more readable…

Please remember to wrap your code with ```, like in markdown

BTW I think session is a good place for your use case

Where Next?

Popular in Questions Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

Other popular topics Top

stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
RisingFromAshes
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement