minimalist_authentication 2.5.2 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/password_resets_controller.rb +1 -1
- data/lib/minimalist_authentication/authenticator.rb +1 -1
- data/lib/minimalist_authentication/controller.rb +1 -1
- data/lib/minimalist_authentication/conversions/merge_password_hash.rb +1 -1
- data/lib/minimalist_authentication/sessions.rb +2 -2
- data/lib/minimalist_authentication/test_helper.rb +4 -2
- data/lib/minimalist_authentication/user.rb +15 -9
- data/lib/minimalist_authentication/verifiable_token.rb +1 -1
- data/lib/minimalist_authentication/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7729e88f86ac9b5f9a20bc3ea20376c3ca4357cba72ee64fd9ff6b43f303d33f
|
4
|
+
data.tar.gz: 263033c938eabe257b2059d0d04ca032b5f7ff49d718c78146e125fd719dcb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a722621655bbd7edaf447364ecd240239a2178824d503a152f2d420080eed6735f4f701a43ff2d9476fc1cf20f1875b1519c075a6cfea5a7f8f81a0816a425d3
|
7
|
+
data.tar.gz: a0b0879d07451c6c0567578d199746326524c38c36d55aaf3315f7f9f355d05d98884628a7df30ec8befd79c29751a6ea6440f983512cb9953f89a3b931d9e9f
|
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
|
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(
|
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:
|
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
|
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 ||=
|
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).
|
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
|
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:
|
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
|
-
|
6
|
-
|
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,16 +6,14 @@ module MinimalistAuthentication
|
|
6
6
|
module User
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
GUEST_USER_EMAIL
|
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.
|
15
|
-
|
13
|
+
attribute :password, :string
|
16
14
|
|
17
15
|
# Force validations for a blank password.
|
18
|
-
|
16
|
+
attribute :password_required, :boolean, default: false
|
19
17
|
|
20
18
|
# Hashes and stores the password on save.
|
21
19
|
before_save :hash_password
|
@@ -33,7 +31,7 @@ module MinimalistAuthentication
|
|
33
31
|
validates(
|
34
32
|
:password,
|
35
33
|
confirmation: true,
|
36
|
-
length: {
|
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
|
-
#
|
112
|
+
# Returns a MinimalistAuthentication::Password object.
|
107
113
|
def password_object
|
108
114
|
Password.new(password_hash)
|
109
115
|
end
|
@@ -112,7 +118,7 @@ module MinimalistAuthentication
|
|
112
118
|
# stored OR are attempting to set a new password. Set **password_required**
|
113
119
|
# to true to force validations even when the password field is blank.
|
114
120
|
def validate_password?
|
115
|
-
active? && (password_hash.blank? || password
|
121
|
+
active? && (password_hash.blank? || password? || password_required?)
|
116
122
|
end
|
117
123
|
|
118
124
|
# Validate email for active users.
|
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.
|
4
|
+
version: 2.6.1
|
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:
|
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:
|
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.
|
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.
|