@@ -95,17 +95,7 @@ if Code.ensure_loaded?(Igniter) do
9595 "Which Phoenix router should be modified to allow authentication?"
9696 )
9797
98- with { igniter , router }
99- when not is_nil ( router ) <-
100- Igniter.Libs.Phoenix . select_router (
101- igniter ,
102- "Which Phoenix router should be modified to allow authentication?"
103- ) ,
104- { igniter , [ endpoint | _ ] } <-
105- Igniter.Libs.Phoenix . endpoints_for_router (
106- igniter ,
107- router
108- ) do
98+ if router do
10999 web_module = Igniter.Libs.Phoenix . web_module ( igniter )
110100 overrides = Igniter.Libs.Phoenix . web_module_name ( igniter , "AuthOverrides" )
111101 otp_app = Igniter.Project.Application . app_name ( igniter )
@@ -116,26 +106,17 @@ if Code.ensure_loaded?(Igniter) do
116106 |> setup_routes_alias ( )
117107 |> warn_on_missing_modules ( options , argv , install? )
118108 |> do_or_explain_tailwind_changes ( )
119- |> create_auth_controller ( otp_app , endpoint )
109+ |> create_auth_controller ( otp_app )
120110 |> create_overrides_module ( overrides )
121111 |> add_auth_routes ( overrides , options , router , web_module )
122112 |> create_live_user_auth ( web_module )
123113 else
124- { igniter , nil } ->
125- igniter
126- |> Igniter . add_warning ( """
127- AshAuthenticationPhoenix installer could not find a Phoenix router. Skipping installation.
128-
129- Set up a phoenix router and reinvoke the installer with `mix igniter.install ash_authentication_phoenix`.
130- """ )
131-
132- { igniter , [ ] } ->
133- igniter
134- |> Igniter . add_warning ( """
135- AshAuthenticationPhoenix installer could not find any Phoenix endpoints attached to the router you selected. Skipping installation.
114+ igniter
115+ |> Igniter . add_warning ( """
116+ AshAuthenticationPhoenix installer could not find a Phoenix router. Skipping installation.
136117
137- Set up a phoenix endpoint and reinvoke the installer with `mix igniter.install ash_authentication_phoenix`.
138- """ )
118+ Set up a phoenix router and reinvoke the installer with `mix igniter.install ash_authentication_phoenix`.
119+ """ )
139120 end
140121 end
141122
@@ -345,7 +326,7 @@ if Code.ensure_loaded?(Igniter) do
345326 )
346327 end
347328
348- defp create_auth_controller ( igniter , otp_app , endpoint ) do
329+ defp create_auth_controller ( igniter , otp_app ) do
349330 Igniter.Project.Module . create_module (
350331 igniter ,
351332 Igniter.Libs.Phoenix . web_module_name ( igniter , "AuthController" ) ,
@@ -363,12 +344,10 @@ if Code.ensure_loaded?(Igniter) do
363344 _ -> "You are now signed in"
364345 end
365346
366- {:ok, %{"jti" => jti}} = AshAuthentication.Jwt.peek(token)
367-
368347 conn
369348 |> delete_session(:return_to)
370349 |> store_in_session(user)
371- |> put_session(:live_socket_id, "users_socket: \# {jti}" )
350+ |> set_live_socket_id(token )
372351 # If your resource has a different name, update the assign name here (i.e :current_admin)
373352 |> assign(:current_user, user)
374353 |> put_flash(:info, message)
@@ -401,14 +380,10 @@ if Code.ensure_loaded?(Igniter) do
401380 def sign_out(conn, _params) do
402381 return_to = get_session(conn, :return_to) || ~p"/"
403382
404- live_socket_id =
405- get_session(conn, :live_socket_id)
406-
407383 conn
408384 |> clear_session(:#{ otp_app } )
409385 |> put_flash(:info, "You are now signed out")
410386 |> redirect(to: return_to)
411- |> tap(fn _ -> #{ inspect ( endpoint ) } .broadcast(live_socket_id, "disconnect", %{}) end)
412387 end
413388 """
414389 )
0 commit comments