live_beats/lib/live_beats_web/controllers/redirect_controller.ex

16 lines
383 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
2022-11-17 20:36:58 +00:00
redirect(conn, to: ~p"/signin")
2021-11-09 11:20:10 +00:00
end
end
end