Skip to content

Commit 9134900

Browse files
authored
Merge pull request rails#384 from rails/flavorjones-add-sessions-template
introduce specialized view for rails 8 authentication generator
2 parents 84c08f8 + 6116343 commit 9134900

File tree

6 files changed

+118
-2
lines changed

6 files changed

+118
-2
lines changed

.github/workflows/upstream.yml

+24-2
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,42 @@ on:
1414
- .github/workflows/upstream.yml # this file
1515

1616
jobs:
17+
tests:
18+
name: "tests (rails main)"
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
ruby: ["3.3"]
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: ruby/setup-ruby@v1
27+
with:
28+
ruby-version: ${{matrix.ruby}}
29+
- run: |
30+
rm Gemfile.lock
31+
bundle remove actionmailer
32+
git clone --depth 1 --branch main https://github.com/rails/rails
33+
bundle add actionmailer --path=rails
34+
bundle add railties --path=rails
35+
bundle install
36+
- name: Run tests
37+
run: bin/test
38+
1739
user-journey:
1840
name: "user-journey (rails main)"
41+
runs-on: ${{matrix.plat}}-latest
1942
strategy:
2043
fail-fast: false
2144
matrix:
2245
plat: ["ubuntu", "windows", "macos"]
23-
runs-on: ${{matrix.plat}}-latest
2446
env:
2547
RAILSOPTS: --git=https://github.com/rails/rails --branch main
2648
steps:
2749
- uses: actions/checkout@v4
2850
- uses: ruby/setup-ruby@v1
2951
with:
30-
ruby-version: "3.2"
52+
ruby-version: "3.3"
3153
bundler: latest
3254
- run: test/integration/user_journey_test.sh
3355
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "rails/generators/erb/authentication/authentication_generator"
2+
3+
module Tailwindcss
4+
module Generators
5+
class AuthenticationGenerator < Erb::Generators::AuthenticationGenerator
6+
source_root File.expand_path("templates", __dir__)
7+
end
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="mx-auto md:w-2/3 w-full">
2+
<%% if alert = flash[:alert] %>
3+
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%%= alert %></p>
4+
<%% end %>
5+
6+
<h1 class="font-bold text-4xl">Update your password</h1>
7+
8+
<%%= form_with url: password_path(params[:token]), method: :put, class: "contents" do |form| %>
9+
<div class="my-5">
10+
<%%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: "Enter new password", maxlength: 72, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
11+
</div>
12+
13+
<div class="my-5">
14+
<%%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: "Repeat new password", maxlength: 72, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
15+
</div>
16+
17+
<div class="inline">
18+
<%%= form.submit "Save", class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
19+
</div>
20+
<%% end %>
21+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="mx-auto md:w-2/3 w-full">
2+
<%% if alert = flash[:alert] %>
3+
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%%= alert %></p>
4+
<%% end %>
5+
6+
<h1 class="font-bold text-4xl">Forgot your password?</h1>
7+
8+
<%%= form_with url: passwords_path, class: "contents" do |form| %>
9+
<div class="my-5">
10+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address], class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
11+
</div>
12+
13+
<div class="inline">
14+
<%%= form.submit "Email reset instructions", class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
15+
</div>
16+
<%% end %>
17+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="mx-auto md:w-2/3 w-full">
2+
<%% if alert = flash[:alert] %>
3+
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%%= alert %></p>
4+
<%% end %>
5+
6+
<%% if notice = flash[:notice] %>
7+
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%%= notice %></p>
8+
<%% end %>
9+
10+
<h1 class="font-bold text-4xl">Sign in</h1>
11+
12+
<%%= form_with url: session_url, class: "contents" do |form| %>
13+
<div class="my-5">
14+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address], class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
15+
</div>
16+
17+
<div class="my-5">
18+
<%%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
19+
</div>
20+
21+
<div class="col-span-6 sm:flex sm:items-center sm:gap-4">
22+
<div class="inline">
23+
<%%= form.submit "Sign in", class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
24+
</div>
25+
26+
<div class="mt-4 text-sm text-gray-500 sm:mt-0">
27+
<%%= link_to "Forgot password?", new_password_path, class: "text-gray-700 underline" %>
28+
</div>
29+
</div>
30+
<%% end %>
31+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require "test_helper"
2+
3+
if Rails::VERSION::MAJOR >= 8
4+
require "generators/tailwindcss/authentication/authentication_generator"
5+
6+
class Tailwindcss::Generators::AuthenticationGeneratorTest < Rails::Generators::TestCase
7+
tests Tailwindcss::Generators::AuthenticationGenerator
8+
destination TAILWINDCSS_TEST_APP_ROOT
9+
10+
test "generates the new session template" do
11+
run_generator
12+
13+
assert_file "app/views/sessions/new.html.erb"
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)