minimalist_authentication 2.5.2 → 2.6.0

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: 84db557ccbc7f085f52ff84ffedd5f174e8e3b14e7a2364389fe256b8373c120
4
- data.tar.gz: fec50087c8cb8098e16d57fbf429096dbc43c87d66d9155947dd807cc54e5c99
3
+ metadata.gz: d31aea6a71210e6ef2811dd5ea7d4f11654ff06cb3c5f92ace5ed00dd7d68d30
4
+ data.tar.gz: 1cb2c601a6effedef5bdc61960c7e08d7947083c4f755646b92c188c50e0a96f
5
5
  SHA512:
6
- metadata.gz: bca2d80847868c1929355733baab209436d7cfb0caa09289371626fa199924171e13359e2b3c38403cb30e8038614652cd042f903321622dfaca3d1582e179f3
7
- data.tar.gz: ceed88e53ee975e757c9fd939e2e68a838f9219cfe8afd7b4a266f907521ecc5c70f15b68376f4f2764f52944709e9e0ef4a6f7a9554ae54ca3b87ce97a8a001
6
+ metadata.gz: ba68753ea4d7f106aa8c26b0972ea0d2cdc36ab5991f4ac6824fde2000603b6bae011e949d978e948ce35af00551aff8b47b943a48589f834df4242e7e889298
7
+ data.tar.gz: afbcc93b12b3926d7b799267aede7ccef00ac9137f0320c0d00079035a7b81f099fda617369d445d7abea52521c32fca4317cf1a81d19022905bbe0f610bb3ab
data/README.md CHANGED
@@ -62,7 +62,7 @@ end
62
62
  ```
63
63
 
64
64
  ## Configuration
65
- Customize the configuration with an initializer. Create a **minimalist_authentication.rb** file in /Users/baldwina/git/brightways/config/initializers.
65
+ Customize the configuration with an initializer. Create a **minimalist_authentication.rb** file in config/initializers.
66
66
  ```ruby
67
67
  MinimalistAuthentication.configure do |configuration|
68
68
  configuration.user_model_name = 'CustomModelName' # default is '::User'
@@ -84,7 +84,7 @@ fixture users.
84
84
  ```yaml
85
85
  example_user:
86
86
  email: user@example.com
87
- password_hash: <%= MinimalistAuthentication::Password.create('password') %>
87
+ password_hash: <%= MinimalistAuthentication::Password.create("test-password") %>
88
88
  ```
89
89
 
90
90
 
@@ -25,7 +25,7 @@ class PasswordResetsController < ApplicationController
25
25
  def user
26
26
  return unless URI::MailTo::EMAIL_REGEXP.match?(email)
27
27
 
28
- @user ||= MinimalistAuthentication.configuration.user_model.active.email_verified.find_by(email: email)
28
+ @user ||= MinimalistAuthentication.configuration.user_model.active.email_verified.find_by(email:)
29
29
  end
30
30
 
31
31
  def email
@@ -21,7 +21,7 @@ module MinimalistAuthentication
21
21
  field = (hash.keys & LOGIN_FIELDS).first
22
22
 
23
23
  # Attempt to authenticate user
24
- new(field: field, value: hash[field], password: hash["password"]).authenticated_user
24
+ new(field:, value: hash[field], password: hash["password"]).authenticated_user
25
25
  end
26
26
 
27
27
  def initialize(field:, value:, password:)
@@ -15,7 +15,7 @@ module MinimalistAuthentication
15
15
  private
16
16
 
17
17
  def current_user
18
- @current_user ||= (find_session_user || MinimalistAuthentication.configuration.user_model.guest)
18
+ @current_user ||= find_session_user || MinimalistAuthentication.configuration.user_model.guest
19
19
  end
20
20
 
21
21
  def find_session_user
@@ -5,7 +5,7 @@ module MinimalistAuthentication
5
5
  class MergePasswordHash
6
6
  class << self
7
7
  def run!
8
- user_model.where(using_digest_version: 3, password_hash: nil).each do |user|
8
+ user_model.where(using_digest_version: 3, password_hash: nil).find_each do |user|
9
9
  new(user).update!
10
10
  end
11
11
  end
@@ -66,12 +66,12 @@ module MinimalistAuthentication
66
66
  end
67
67
 
68
68
  def attempting_to_verify?
69
- # check if user is attpting to verify their email
69
+ # check if user is attempting to verify their email
70
70
  session["return_to"].to_s[/token/]
71
71
  end
72
72
 
73
73
  def after_authentication_failure
74
- flash.now.alert = t(".alert", identifier: identifier)
74
+ flash.now.alert = t(".alert", identifier:)
75
75
  user
76
76
  render :new, status: :unprocessable_entity
77
77
  end
@@ -2,8 +2,10 @@
2
2
 
3
3
  module MinimalistAuthentication
4
4
  module TestHelper
5
- def login_as(user_fixture_name, password = "password")
6
- post session_path, params: { user: { email: users(user_fixture_name).email, password: password } }
5
+ PASSWORD = "test-password"
6
+
7
+ def login_as(user_fixture_name, password = PASSWORD)
8
+ post session_path, params: { user: { email: users(user_fixture_name).email, password: } }
7
9
  end
8
10
 
9
11
  def current_user
@@ -6,9 +6,7 @@ module MinimalistAuthentication
6
6
  module User
7
7
  extend ActiveSupport::Concern
8
8
 
9
- GUEST_USER_EMAIL = "guest"
10
- PASSWORD_MIN = 8
11
- PASSWORD_MAX = 40
9
+ GUEST_USER_EMAIL = "guest"
12
10
 
13
11
  included do
14
12
  # Stores the plain text password.
@@ -33,7 +31,7 @@ module MinimalistAuthentication
33
31
  validates(
34
32
  :password,
35
33
  confirmation: true,
36
- length: { within: PASSWORD_MIN..PASSWORD_MAX },
34
+ length: { minimum: :password_minimum, maximum: :password_maximum },
37
35
  presence: true,
38
36
  if: :validate_password?
39
37
  )
@@ -87,11 +85,19 @@ module MinimalistAuthentication
87
85
  guest?
88
86
  end
89
87
 
88
+ # Minimum password length
89
+ def password_minimum = 12
90
+
91
+ # Maximum password length
92
+ def password_maximum = 40
93
+
90
94
  private
91
95
 
92
- # Set self.password to password, hash, and save
96
+ # Set self.password to password, hash, and save if user is valid.
93
97
  def update_hash!(password)
94
98
  self.password = password
99
+ return unless valid?
100
+
95
101
  hash_password
96
102
  save
97
103
  end
@@ -103,7 +109,7 @@ module MinimalistAuthentication
103
109
  self.password_hash = Password.create(password)
104
110
  end
105
111
 
106
- # Retuns a MinimalistAuthentication::Password object.
112
+ # Returns a MinimalistAuthentication::Password object.
107
113
  def password_object
108
114
  Password.new(password_hash)
109
115
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MinimalistAuthentication
4
- VERSION = "2.5.2"
4
+ VERSION = "2.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimalist_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Baldwin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-19 00:00:00.000000000 Z
12
+ date: 2024-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bcrypt
@@ -106,14 +106,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 2.7.0
109
+ version: 3.1.0
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.4.15
116
+ rubygems_version: 3.5.11
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: A Rails authentication plugin that takes a minimalist approach.