live_beats/lib/live_beats_web/controllers/redirect_controller.ex

16 lines
405 B
Elixir
Raw Normal View History

2021-11-09 11:20:10 +00:00
defmodule LiveBeatsWeb.RedirectController do
use LiveBeatsWeb, :controller
2021-11-16 20:54:40 +00:00
import LiveBeatsWeb.UserAuth, only: [fetch_current_user: 2]
plug :fetch_current_user
2021-11-09 11:20:10 +00:00
def redirect_authenticated(conn, _) do
if conn.assigns.current_user do
LiveBeatsWeb.UserAuth.redirect_if_user_is_authenticated(conn, [])
else
redirect(conn, to: Routes.sign_in_path(conn, :index))
end
end
end