Router same route for live and old view

Hi,

I have an app done in liveview. The security is done using the Phoenix generator and Only authenticated user can access the app.

Now I want to share on Twitter/Facebook/etc certain page. To do so I have created an old view under /social/playlist/:id path. This path is in a unauthenticatzd pipeline.
Everything works, except that having a different path for the « same thing » disturbs my users :confused: (native sharing from smartphone does not work as expected but my app « sharing to » button works)

Is there a way to say in the router : this path, for authenticated users go to this controller otherwise it goes to this other controller ?

Thanks for any help :slight_smile:

What’s keeping you from doing it in a controller (or live view)?

def action(conn, params) do
  if is_authencitated(conn) do
    # return authenticated response
  else
    # return unauthenticated response
  end
end

Hi,

Thanks for your answer.

I try to avoid as much as possible if. It adds a lot of complexity when using liveview with a lot of conditionnel on_mount/assign

I have used the native share api to hide the real url shared

Thanks

Maybe create a plug which detects authenticated users and forwards to different controllers.