# Programming Phoenix LiveView: :ensure\_authenticated should be :require\_authenticated (p56)

**URL:** <https://forum.devtalk.com/t/programming-phoenix-liveview-ensure-authenticated-should-be-require-authenticated-p56/212384>\
**Category:** PragProg Customers\
**Tags:** book-programming-phoenix-liveview, errata\
**Created:** [26 August 2025 15:02 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-ensure-authenticated-should-be-require-authenticated-p56/212384 "2025-08-26T15:02:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pocketlim](https://forum.devtalk.com/user_avatar/forum.devtalk.com/pocketlim/32/7621_2.png) [@pocketlim](https://forum.devtalk.com/u/pocketlim)\
**Post date:** [26 August 2025 15:02 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-ensure-authenticated-should-be-require-authenticated-p56/212384/1 "2025-08-26T15:02:23Z")

</div>

The line on page 65 (using the PDF) is

```elixir
 on_mount: [{PentoWeb.UserAuth, :ensure_authenticated}] do

```

This is incorrect and will throw an error. Searching through the whole codebase shows that `ensure_authenticated` does not exist. The correct line is

```elixir
on_mount: [{PentoWeb.UserAuth, :require_authenticated}] do

```

Full context:

```elixir
  ## Authentication routes

  scope "/", PentoWeb do
    pipe_through [:browser, :require_authenticated_user]

    live_session :require_authenticated_user,
      root_layout: {PentoWeb.Layouts, :root},
      # Specify the shared on_mount callback here
      on_mount: [{PentoWeb.UserAuth, :require_authenticated}] do
      live "/users/settings", UserLive.Settings, :edit
      live "/users/settings/confirm-email/:token", UserLive.Settings, :confirm_email
      live "/guess", WrongLive
    end

    post "/users/update-password", UserSessionController, :update_password
  end

```

---

<div class="post-metadata">

**Author:** ![monkeini](https://forum.devtalk.com/user_avatar/forum.devtalk.com/monkeini/32/7629_2.png) [@monkeini](https://forum.devtalk.com/u/monkeini)\
**Post date:** [31 August 2025 14:38 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-ensure-authenticated-should-be-require-authenticated-p56/212384/2 "2025-08-31T14:38:23Z")

</div>

Thanks for confirming! Had me searching the codebase, that one.
