Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installer - generate CSRF meta with csrf_token_value #4804

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%%= csrf_meta_tag() %>
<meta name="csrf-token" content={csrf_token_value()}>
<%%= live_title_tag assigns[:page_title] || "<%= @app_module %>", suffix: " · Phoenix Framework" %>
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")}/>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js")}></script>
Expand Down
5 changes: 4 additions & 1 deletion installer/test/phx_new_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ defmodule Mix.Tasks.Phx.NewTest do
assert file =~ ~s|plug Phoenix.LiveDashboard.RequestLogger|
end

assert_file "phx_blog/lib/phx_blog_web/templates/layout/root.html.heex"
assert_file "phx_blog/lib/phx_blog_web/templates/layout/root.html.heex", fn file ->
assert file =~ ~s|<meta name="csrf-token" content={csrf_token_value()}>|
end

assert_file "phx_blog/lib/phx_blog_web/templates/layout/app.html.heex"

assert_file "phx_blog/lib/phx_blog_web/templates/page/index.html.heex", fn file ->
Expand Down
6 changes: 5 additions & 1 deletion installer/test/phx_new_umbrella_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
~r/defmodule PhxUmbWeb.PageView/

assert_file web_path(@app, "lib/#{@app}_web/router.ex"), "defmodule PhxUmbWeb.Router"
assert_file web_path(@app, "lib/#{@app}_web/templates/layout/root.html.heex")

assert_file web_path(@app, "lib/#{@app}_web/templates/layout/root.html.heex"), fn file ->
assert file =~ ~s|<meta name="csrf-token" content={csrf_token_value()}>|
end

assert_file web_path(@app, "lib/#{@app}_web/templates/layout/app.html.heex")
assert_file web_path(@app, "test/#{@app}_web/views/page_view_test.exs"),
"defmodule PhxUmbWeb.PageViewTest"
Expand Down