live_beats/lib/live_beats_web/controllers/redirect_controller.ex
2021-11-16 15:54:40 -05:00

16 lines
405 B
Elixir

defmodule LiveBeatsWeb.RedirectController do
use LiveBeatsWeb, :controller
import LiveBeatsWeb.UserAuth, only: [fetch_current_user: 2]
plug :fetch_current_user
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