administration-zero 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70d7f8e45906155c94abff9d0806c85fdf9c22ad45179a3cc96bf117bbc4aa53
4
- data.tar.gz: b3ffdb6e02eb904ea4198c6e30a31c1e2913d1078c6c41c7bcde2f3d0be64cd4
3
+ metadata.gz: 0055b7410852864619289bb38808d842640bd4287e74569218f777e511e86423
4
+ data.tar.gz: 87b8eeee5181729f9b598a811e9f9482924713722375879eb6fc050c177a4cf8
5
5
  SHA512:
6
- metadata.gz: d25cd7127b720c6f88d70c8563dfdd69d9e62a96fd693777ab0832ccdf700b0ec914fd3246c8c380f7af0813a5da0ea6c74a1a3ffea629ce267bba71759eb95d
7
- data.tar.gz: b147a78d2bbfdfa5b4c93cea8dfa239e5d76eb2f8c788e947c1d31fc3d63c1e172c8c085684bab3a35d4c10042ca0050d572f42ae5c0dfc596f5e7540e513ccc
6
+ metadata.gz: f131a63aa42f5f354d89bbbb12a4a88599e2fe7bb10540e0855fee072324f845c3b14d68e47940acd3eae25ee4e20985c4004071b01ad8ad986ddd31a836d33c
7
+ data.tar.gz: 3c9af28115f6768cc7f92693bb078c406e960b3a332fe81275b309de2fec537cf9ab8e139c5ce2a2a3dea25e76ff020aa6464c803674cdabb0dd18b8cb08d809
data/CHANGELOG.md CHANGED
@@ -0,0 +1,8 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.5] - 2024-01-17
4
+ - Added ransackable_attributes to Admin::User
5
+ - Updated dependencies
6
+ - Fixed scaffold with boolean columns
7
+ - Updated authentication
8
+ - Removed system tests
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- administration-zero (1.0.4)
4
+ administration-zero (1.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,6 +10,7 @@ GEM
10
10
 
11
11
  PLATFORMS
12
12
  x86_64-darwin-21
13
+ x86_64-darwin-23
13
14
 
14
15
  DEPENDENCIES
15
16
  administration-zero!
@@ -1,3 +1,3 @@
1
1
  module AdministrationZero
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -70,9 +70,7 @@ module Admin
70
70
 
71
71
  def create_test_files
72
72
  directory "test_unit/controllers", "test/controllers"
73
- directory "test_unit/system", "test/system"
74
73
  copy_file "test_unit/test_helper.rb", "test/test_helper.rb", force: true
75
- copy_file "test_unit/application_system_test_case.rb", "test/application_system_test_case.rb", force: true
76
74
  end
77
75
  end
78
76
  end
@@ -30,8 +30,8 @@ class Admin::PasswordResetsController < Admin::BaseController
30
30
 
31
31
  private
32
32
  def set_user
33
- @user = Admin::User.find_signed!(params[:token], purpose: :password_reset)
34
- rescue
33
+ @user = Admin::User.find_by_token_for!(:password_reset, params[:token])
34
+ rescue StandardError
35
35
  redirect_to new_admin_password_reset_path, alert: "That password reset link is invalid"
36
36
  end
37
37
 
@@ -8,10 +8,8 @@ class Admin::SessionsController < Admin::BaseController
8
8
  end
9
9
 
10
10
  def create
11
- @user = Admin::User.find_by(email: params[:email])
12
-
13
- if @user && @user.authenticate(params[:password])
14
- session[:admin_user_id] = @user.id; redirect_to(admin_path)
11
+ if user = Admin::User.authenticate_by(email: params[:email], password: params[:password])
12
+ session[:admin_user_id] = user.id; redirect_to(admin_path)
15
13
  else
16
14
  redirect_to admin_sign_in_path(email_hint: params[:email]), alert: "That email or password is incorrect"
17
15
  end
@@ -1,9 +1,9 @@
1
- <script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta19/dist/js/tabler.min.js"></script>
2
- <script src="https://cdn.jsdelivr.net/npm/@rails/ujs@7.0.6/lib/assets/compiled/rails-ujs.min.js"></script>
1
+ <script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta24/dist/js/tabler.min.js"></script>
2
+ <script src="https://cdn.jsdelivr.net/npm/@rails/ujs@7.1.3-4/app/assets/javascripts/rails-ujs.min.js"></script>
3
3
 
4
4
  <!-- Stimulus -->
5
5
  <script type="module">
6
- import { Application, Controller } from "https://cdn.jsdelivr.net/npm/@hotwired/stimulus@3.2.1/+esm"
6
+ import { Application, Controller } from "https://cdn.jsdelivr.net/npm/@hotwired/stimulus@3.2.2/+esm"
7
7
  window.Stimulus = Application.start()
8
8
 
9
9
  Stimulus.register("flash-message", class extends Controller {
@@ -1,5 +1,5 @@
1
1
  <!-- Tabler Core -->
2
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta19/dist/css/tabler.min.css">
2
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta24/dist/css/tabler.min.css">
3
3
 
4
4
  <!-- Customize tabler here -->
5
5
  <style>body {
@@ -1,7 +1,7 @@
1
1
  class Admin::UserMailer < Admin::ApplicationMailer
2
2
  def password_reset
3
3
  @user = params[:user]
4
- @signed_id = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
4
+ @signed_id = @user.generate_token_for(:password_reset)
5
5
 
6
6
  mail to: @user.email, subject: "Reset your password"
7
7
  end
@@ -1,10 +1,16 @@
1
1
  class Admin::User < Admin::ApplicationRecord
2
2
  has_secure_password
3
3
 
4
+ generates_token_for :password_reset, expires_in: 20.minutes do
5
+ password_salt.last(10)
6
+ end
7
+
4
8
  validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
5
9
  validates :password, allow_nil: true, length: { minimum: 12 }, format: { with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/ }
6
10
 
7
- before_validation if: -> { email.present? } do
8
- self.email = email.downcase.strip
11
+ normalizes :email, with: -> { _1.strip.downcase }
12
+
13
+ def self.ransackable_attributes(auth_object = nil)
14
+ %w[email created_at]
9
15
  end
10
16
  end
@@ -3,8 +3,7 @@ require "test_helper"
3
3
  class Admin::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
4
4
  setup do
5
5
  @user = admin_users(:lazaro_nixon)
6
- @sid = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
7
- @sid_exp = @user.signed_id(purpose: :password_reset, expires_in: 0.minutes)
6
+ @sid = @user.generate_token_for(:password_reset)
8
7
  end
9
8
 
10
9
  test "should get new" do
@@ -18,7 +17,7 @@ class Admin::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
18
17
  end
19
18
 
20
19
  test "should send a password reset email" do
21
- assert_enqueued_email_with Admin::UserMailer, :password_reset, args: { user: @user } do
20
+ assert_enqueued_email_with Admin::UserMailer, :password_reset, params: { user: @user } do
22
21
  post admin_password_reset_url, params: { email: @user.email }
23
22
  end
24
23
 
@@ -40,7 +39,8 @@ class Admin::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
40
39
  end
41
40
 
42
41
  test "should not update password with expired token" do
43
- patch admin_password_reset_url, params: { token: @sid_exp, password: "Secret6*4*2*", password_confirmation: "Secret6*4*2*" }
42
+ travel 30.minutes
43
+ patch admin_password_reset_url, params: { token: @sid, password: "Secret6*4*2*", password_confirmation: "Secret6*4*2*" }
44
44
 
45
45
  assert_redirected_to new_admin_password_reset_url
46
46
  assert_equal "That password reset link is invalid", flash[:alert]
@@ -18,7 +18,7 @@
18
18
  <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: "form-control" %>
19
19
  <%%= tag.div <%= singular_name %>.errors[:<%= attribute.column_name %>].first, class: "invalid-feedback" %>
20
20
  </div>
21
- <% elsif attribute.field_type == :check_box -%>
21
+ <% elsif attribute.field_type == :checkbox -%>
22
22
  <%%= form.label :<%= attribute.column_name %>, class: "form-check-label col-md-3 col-form-label" %>
23
23
  <div class="col-md px-0">
24
24
  <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: "form-check-input" %>
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: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2025-01-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -71,14 +71,10 @@ files:
71
71
  - lib/generators/admin/install/templates/models/application_record.rb
72
72
  - lib/generators/admin/install/templates/seeds.rb
73
73
  - lib/generators/admin/install/templates/test_unit/admin_users.yml
74
- - lib/generators/admin/install/templates/test_unit/application_system_test_case.rb
75
74
  - lib/generators/admin/install/templates/test_unit/controllers/admin/home_controller_test.rb
76
75
  - lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
77
76
  - lib/generators/admin/install/templates/test_unit/controllers/admin/sessions_controller_test.rb
78
77
  - lib/generators/admin/install/templates/test_unit/controllers/admin/users_controller_test.rb
79
- - lib/generators/admin/install/templates/test_unit/system/admin/password_resets_test.rb
80
- - lib/generators/admin/install/templates/test_unit/system/admin/sessions_test.rb
81
- - lib/generators/admin/install/templates/test_unit/system/admin/users_test.rb
82
78
  - lib/generators/admin/install/templates/test_unit/test_helper.rb
83
79
  - lib/generators/admin/scaffold/USAGE
84
80
  - lib/generators/admin/scaffold/scaffold_generator.rb
@@ -112,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
108
  - !ruby/object:Gem::Version
113
109
  version: '0'
114
110
  requirements: []
115
- rubygems_version: 3.3.7
111
+ rubygems_version: 3.5.10
116
112
  signing_key:
117
113
  specification_version: 4
118
114
  summary: An administration system generator for Rails applications
@@ -1,15 +0,0 @@
1
- require "test_helper"
2
-
3
- class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
- driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5
-
6
- def sign_in_admin_as(user)
7
- visit admin_sign_in_url
8
- fill_in :email, with: user.email
9
- fill_in :password, with: "Secret1*3*5*"
10
- click_on "Sign in"
11
- assert_current_path admin_url
12
-
13
- user
14
- end
15
- end
@@ -1,28 +0,0 @@
1
- require "application_system_test_case"
2
-
3
- class Admin::PasswordResetsTest < ApplicationSystemTestCase
4
- setup do
5
- @user = admin_users(:lazaro_nixon)
6
- @sid = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
7
- end
8
-
9
- test "sending a password reset email" do
10
- visit admin_sign_in_url
11
- click_on "I forgot password"
12
-
13
- fill_in "Email", with: @user.email
14
- click_on "Send me new password"
15
-
16
- assert_text "Check your email for reset instructions"
17
- end
18
-
19
- test "updating password" do
20
- visit edit_admin_password_reset_url(token: @sid)
21
-
22
- fill_in "New password", with: "Secret6*4*2*"
23
- fill_in "Confirm new password", with: "Secret6*4*2*"
24
- click_on "Save changes"
25
-
26
- assert_text "Your password was reset successfully. Please sign in"
27
- end
28
- end
@@ -1,24 +0,0 @@
1
- require "application_system_test_case"
2
-
3
- class Admin::SessionsTest < ApplicationSystemTestCase
4
- setup do
5
- @user = admin_users(:lazaro_nixon)
6
- end
7
-
8
- test "signing in" do
9
- visit admin_sign_in_url
10
- fill_in "Email", with: @user.email
11
- fill_in "Password", with: "Secret1*3*5*"
12
- click_on "Sign in"
13
-
14
- assert_selector "h1", text: "Admin::Home#index"
15
- end
16
-
17
- test "signing out" do
18
- sign_in_admin_as @user
19
- click_on "Paweł Kuna"
20
- click_on "Logout"
21
-
22
- assert_selector "h1", text: "Login to your account"
23
- end
24
- end
@@ -1,43 +0,0 @@
1
- require "application_system_test_case"
2
-
3
- class Admin::UsersTest < ApplicationSystemTestCase
4
- setup do
5
- @user = sign_in_admin_as(admin_users(:lazaro_nixon))
6
- end
7
-
8
- test "visiting the index" do
9
- visit admin_users_url
10
- assert_selector "h1", text: "Users"
11
- end
12
-
13
- test "should create user" do
14
- visit admin_users_url
15
- click_on "New user"
16
-
17
- fill_in "Email", with: "lazaronixon@hey.com"
18
- fill_in "Password", with: "Secret1*3*5*"
19
- fill_in "Password confirmation", with: "Secret1*3*5*"
20
- click_on "Create User"
21
-
22
- assert_text "User was successfully created"
23
- end
24
-
25
- test "should update user" do
26
- visit admin_user_url(@user)
27
- click_on "Edit user"
28
-
29
- fill_in "Email", with: @user.email
30
- fill_in "Password", with: "NewSecret1*3*5*"
31
- fill_in "Password confirmation", with: "NewSecret1*3*5*"
32
- click_on "Update User"
33
-
34
- assert_text "User was successfully updated"
35
- end
36
-
37
- test "should destroy user" do
38
- visit admin_user_url(@user)
39
- page.accept_confirm { click_on "Delete user" }
40
-
41
- assert_text "User was successfully destroyed"
42
- end
43
- end