administration-zero 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/administration_zero/version.rb +1 -1
  4. data/lib/generators/admin/install/templates/controllers/admin/password_resets_controller.rb +1 -1
  5. data/lib/generators/admin/install/templates/controllers/admin/sessions_controller.rb +0 -1
  6. data/lib/generators/admin/install/templates/erb/admin/application/_flash_messages.html.erb +3 -1
  7. data/lib/generators/admin/install/templates/erb/admin/application/_page_header_breadcrumb.html.erb +2 -2
  8. data/lib/generators/admin/install/templates/erb/admin/password_resets/edit.html.erb +1 -1
  9. data/lib/generators/admin/install/templates/erb/admin/password_resets/new.html.erb +1 -1
  10. data/lib/generators/admin/install/templates/erb/admin/sessions/new.html.erb +1 -1
  11. data/lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset.html.erb +14 -0
  12. data/lib/generators/admin/install/templates/erb/admin/user_mailer/{password_reset_provision.text.erb → password_reset.text.erb} +0 -0
  13. data/lib/generators/admin/install/templates/mailers/admin/application_mailer.rb +0 -1
  14. data/lib/generators/admin/install/templates/mailers/admin/user_mailer.rb +1 -1
  15. data/lib/generators/admin/install/templates/migrations/create_admin_users.rb.tt +2 -2
  16. data/lib/generators/admin/install/templates/models/admin/application_record.rb +1 -4
  17. data/lib/generators/admin/install/templates/models/admin/user.rb +3 -6
  18. data/lib/generators/admin/install/templates/test_unit/application_system_test_case.rb +1 -1
  19. data/lib/generators/admin/install/templates/test_unit/controllers/admin/home_controller_test.rb +1 -1
  20. data/lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb +1 -1
  21. data/lib/generators/admin/install/templates/test_unit/controllers/admin/sessions_controller_test.rb +1 -1
  22. data/lib/generators/admin/install/templates/test_unit/controllers/admin/users_controller_test.rb +1 -1
  23. data/lib/generators/admin/install/templates/test_unit/system/admin/sessions_test.rb +1 -1
  24. data/lib/generators/admin/install/templates/test_unit/system/admin/users_test.rb +1 -1
  25. data/lib/generators/admin/install/templates/test_unit/test_helper.rb +1 -1
  26. data/lib/generators/admin/scaffold/templates/functional_test.rb.tt +1 -1
  27. data/lib/generators/admin/scaffold/templates/system_test.rb.tt +1 -1
  28. metadata +4 -4
  29. data/lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset_provision.html.erb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 663bd62eb687f4ebb0a1cd879bc3dae595bc726c7cc29a91431f5e82f133033a
4
- data.tar.gz: 0ca18a859d138db6b2f50383a1c561df8131466ece26093cfd797184e359f86b
3
+ metadata.gz: dfad604f4745dd7570ce2d3312be76883c4628d78b68f9cf73e895524e3a5b09
4
+ data.tar.gz: 8075becb0053683c3829418f3638203ec18e68c8457889e991d0f00330272c79
5
5
  SHA512:
6
- metadata.gz: f4d3486f4dcb59a2fb0aa41d4968106fc4cf6f8569f85610823cb0d832da093d380366ebb4a8ecdaf9aac5767635e2d9d557343b34b3189dc667f9566cccd7bf
7
- data.tar.gz: 65eebeed7cbf48951eed8a0feef6242b2b32f37302726f0a4f9b74b20bb456564ad18d1ab8bb4b3e9dfa5f56269ed09eba1b7e881ebb77cc0497ef5264956f9c
6
+ metadata.gz: 232ad1c394f2587baab5d9756a9bbd5a5aeb7a2367a62e650a7005ac8f65159d9394871295005aaa54834e69c53ce272d8366faec645498981b81f1770d88403
7
+ data.tar.gz: e19a765822a158ff63482d267ab4d3e231ca5024f21abf239ac783f4818d3629c6731bb1967c5a7b674992ea404b0b38efdecf341f1e8da92e71a07577878aee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- administration-zero (0.0.10)
4
+ administration-zero (0.0.11)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module AdministrationZero
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -13,7 +13,7 @@ class Admin::PasswordResetsController < Admin::ApplicationController
13
13
 
14
14
  def create
15
15
  if @admin_user = Admin::User.find_by(email: params[:email])
16
- Admin::UserMailer.with(admin_user: @admin_user).password_reset_provision.deliver_later
16
+ Admin::UserMailer.with(admin_user: @admin_user).password_reset.deliver_later
17
17
  redirect_to admin_sign_in_path, notice: "Check your email for reset instructions"
18
18
  else
19
19
  redirect_to new_admin_password_reset_path, alert: "Sorry, we didn't recognize that email address"
@@ -12,7 +12,6 @@ class Admin::SessionsController < Admin::ApplicationController
12
12
 
13
13
  if @admin_user && @admin_user.authenticate(params[:password])
14
14
  session[:admin_user_id] = @admin_user.id
15
-
16
15
  redirect_to admin_path
17
16
  else
18
17
  redirect_to admin_sign_in_path(email_hint: params[:email]), alert: "That email or password is incorrect"
@@ -1,4 +1,6 @@
1
- <% flash.each do |name, message| %>
1
+ <% message = notice || alert %>
2
+
3
+ <% if message %>
2
4
  <div class="position-fixed start-50 translate-middle-x" style="z-index: 1030; top: 8rem;">
3
5
  <div class="toast hide text-center text-white bg-dark border-0" data-controller="flash-message">
4
6
  <div class="toast-body">
@@ -6,7 +6,7 @@
6
6
  <%= yield %>
7
7
  </ol>
8
8
  </div>
9
- <h2 class="page-title">
9
+ <h1 class="page-title">
10
10
  <span class="text-truncate"><%= title %></span>
11
- </h2>
11
+ </h1>
12
12
  </div>
@@ -1,6 +1,6 @@
1
1
  <%= form_with(url: admin_password_reset_path, method: :patch, class: "card card-md") do |form| %>
2
2
  <div class="card-body">
3
- <h2 class="card-title text-center mb-4">Reset password</h2>
3
+ <h1 class="card-title text-center mb-4">Reset password</h1>
4
4
 
5
5
  <%= hidden_field_tag :token, params[:token] %>
6
6
 
@@ -1,6 +1,6 @@
1
1
  <%= form_with(url: admin_password_reset_path, class: "card card-md") do |form| %>
2
2
  <div class="card-body">
3
- <h2 class="card-title text-center mb-4">Forgot password</h2>
3
+ <h1 class="card-title text-center mb-4">Forgot password</h1>
4
4
  <p class="text-muted mb-4">Enter your email address and your password will be reset and emailed to you.</p>
5
5
  <div class="mb-3">
6
6
  <%= form.label :email, class: "form-label" %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with(url: admin_sign_in_path, class: "card card-md") do |form| %>
2
2
  <div class="card-body">
3
- <h2 class="card-title text-center mb-4">Login to your account</h2>
3
+ <h1 class="card-title text-center mb-4">Login to your account</h1>
4
4
  <div class="mb-3">
5
5
  <%= form.label :email, class: "form-label" %>
6
6
  <%= form.email_field :email, value: params[:email_hint], placeholder: "Enter email", autofocus: true, required: true, autocomplete: "email", class:"form-control" %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ </head>
6
+ <body>
7
+ <p>Hey there,</p>
8
+ <p>Can't remember your password for <strong><%= @admin_user.email %></strong>? That's OK, it happens. Just hit the link below to set a new one.</p>
9
+ <p><%= link_to "Reset my password", edit_admin_password_reset_url(token: @signed_id) %></p>
10
+ <p>If you did not request a password reset you can safely ignore this email, it expires in 20 minutes. Only someone with access to this email account can reset your password.</p>
11
+ <hr>
12
+ <p>Have questions or need help? Just reply to this email and our support team will help you sort it out.</p>
13
+ </body>
14
+ </html>
@@ -1,4 +1,3 @@
1
1
  class Admin::ApplicationMailer < ActionMailer::Base
2
2
  default from: "from@example.com"
3
- layout "mailer"
4
3
  end
@@ -1,5 +1,5 @@
1
1
  class Admin::UserMailer < Admin::ApplicationMailer
2
- def password_reset_provision
2
+ def password_reset
3
3
  @admin_user = params[:admin_user]
4
4
  @signed_id = @admin_user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
5
5
 
@@ -1,8 +1,8 @@
1
1
  class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
3
  create_table :admin_users do |t|
4
- t.string :email
5
- t.string :password_digest
4
+ t.string :email, null: false
5
+ t.string :password_digest, null: false
6
6
 
7
7
  t.timestamps
8
8
  end
@@ -1,6 +1,3 @@
1
1
  class Admin::ApplicationRecord < ActiveRecord::Base
2
- include SpreadsheetArchitect
3
-
4
- self.abstract_class = true
5
- self.table_name_prefix = "admin_"
2
+ include SpreadsheetArchitect; self.abstract_class = true; self.table_name_prefix = "admin_"
6
3
  end
@@ -1,13 +1,10 @@
1
1
  class Admin::User < Admin::ApplicationRecord
2
2
  has_secure_password
3
3
 
4
- validates :email, presence: true, uniqueness: true
5
- validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/
6
-
7
- validates_length_of :password, minimum: 12, allow_nil: true
8
- validates_format_of :password, with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/, allow_nil: true, message: "might easily be guessed"
4
+ validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
5
+ validates :password, allow_nil: true, length: { minimum: 12 }, format: { with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/ }
9
6
 
10
7
  before_validation do
11
- self.email = email.downcase.strip
8
+ self.email = email.try(:downcase).try(:strip)
12
9
  end
13
10
  end
@@ -3,7 +3,7 @@ require "test_helper"
3
3
  class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
4
  driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5
5
 
6
- def admin_sign_in_as(user)
6
+ def sign_in_admin_as(user)
7
7
  visit admin_sign_in_url
8
8
  fill_in :email, with: user.email
9
9
  fill_in :password, with: "Secret1*3*5*"
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  class Admin::HomeControllerTest < ActionDispatch::IntegrationTest
4
4
  setup do
5
- @admin_user = admin_sign_in_as(admin_users(:lazaro_nixon))
5
+ @admin_user = sign_in_admin_as(admin_users(:lazaro_nixon))
6
6
  end
7
7
 
8
8
  test "should get index" do
@@ -18,7 +18,7 @@ class Admin::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
18
18
  end
19
19
 
20
20
  test "should send a password reset email" do
21
- assert_enqueued_email_with Admin::UserMailer, :password_reset_provision, args: { admin_user: @admin_user } do
21
+ assert_enqueued_email_with Admin::UserMailer, :password_reset, args: { admin_user: @admin_user } do
22
22
  post admin_password_reset_url, params: { email: @admin_user.email }
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ class Admin::SessionsControllerTest < ActionDispatch::IntegrationTest
28
28
  end
29
29
 
30
30
  test "should sign out" do
31
- admin_sign_in_as @admin_user
31
+ sign_in_admin_as @admin_user
32
32
 
33
33
  delete admin_sign_out_url
34
34
  assert_redirected_to admin_sign_in_url
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
4
4
  setup do
5
- @admin_user = admin_sign_in_as(admin_users(:lazaro_nixon))
5
+ @admin_user = sign_in_admin_as(admin_users(:lazaro_nixon))
6
6
  end
7
7
 
8
8
  test "should get index" do
@@ -15,7 +15,7 @@ class Admin::SessionsTest < ApplicationSystemTestCase
15
15
  end
16
16
 
17
17
  test "signing out" do
18
- admin_sign_in_as @admin_user
18
+ sign_in_admin_as @admin_user
19
19
  click_on "Paweł Kuna"
20
20
  click_on "Logout"
21
21
 
@@ -2,7 +2,7 @@ require "application_system_test_case"
2
2
 
3
3
  class Admin::UsersTest < ApplicationSystemTestCase
4
4
  setup do
5
- @admin_user = admin_sign_in_as(admin_users(:lazaro_nixon))
5
+ @admin_user = sign_in_admin_as(admin_users(:lazaro_nixon))
6
6
  end
7
7
 
8
8
  test "visiting the index" do
@@ -10,7 +10,7 @@ class ActiveSupport::TestCase
10
10
  fixtures :all
11
11
 
12
12
  # Add more helper methods to be used by all tests here...
13
- def admin_sign_in_as(user)
13
+ def sign_in_admin_as(user)
14
14
  post(admin_sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }); user
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
6
6
 
7
7
  <%- end -%>
8
8
  setup do
9
- @admin_user = admin_sign_in_as admin_users(:lazaro_nixon)
9
+ @admin_user = sign_in_admin_as admin_users(:lazaro_nixon)
10
10
  @<%= singular_table_name %> = <%= fixture_name %>(:one)
11
11
  end
12
12
 
@@ -2,7 +2,7 @@ require "application_system_test_case"
2
2
 
3
3
  class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
4
4
  setup do
5
- @admin_user = admin_sign_in_as(admin_users(:lazaro_nixon))
5
+ @admin_user = sign_in_admin_as(admin_users(:lazaro_nixon))
6
6
  @<%= singular_table_name %> = <%= fixture_name %>(:one)
7
7
  end
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administration-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-05-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -52,8 +52,8 @@ files:
52
52
  - lib/generators/admin/install/templates/erb/admin/password_resets/edit.html.erb
53
53
  - lib/generators/admin/install/templates/erb/admin/password_resets/new.html.erb
54
54
  - lib/generators/admin/install/templates/erb/admin/sessions/new.html.erb
55
- - lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset_provision.html.erb
56
- - lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset_provision.text.erb
55
+ - lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset.html.erb
56
+ - lib/generators/admin/install/templates/erb/admin/user_mailer/password_reset.text.erb
57
57
  - lib/generators/admin/install/templates/erb/admin/users/_form.html.erb
58
58
  - lib/generators/admin/install/templates/erb/admin/users/edit.html.erb
59
59
  - lib/generators/admin/install/templates/erb/admin/users/index.html.erb
@@ -1,11 +0,0 @@
1
- <p>Hey there,</p>
2
-
3
- <p>Can't remember your password for <strong><%= @admin_user.email %></strong>? That's OK, it happens. Just hit the link below to set a new one.</p>
4
-
5
- <p><%= link_to "Reset my password", edit_admin_password_reset_url(token: @signed_id) %></p>
6
-
7
- <p>If you did not request a password reset you can safely ignore this email, it expires in 20 minutes. Only someone with access to this email account can reset your password.</p>
8
-
9
- <hr>
10
-
11
- <p>Have questions or need help? Just reply to this email and our support team will help you sort it out.</p>