minimalist_authentication 2.5.1 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2 -2
- 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 +12 -6
- 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: d31aea6a71210e6ef2811dd5ea7d4f11654ff06cb3c5f92ace5ed00dd7d68d30
|
4
|
+
data.tar.gz: 1cb2c601a6effedef5bdc61960c7e08d7947083c4f755646b92c188c50e0a96f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
@@ -46,7 +46,7 @@ module MinimalistAuthentication
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def store_location
|
49
|
-
session["return_to"] = request.
|
49
|
+
session["return_to"] = url_for(request.params.merge(format: :html, only_path: true))
|
50
50
|
end
|
51
51
|
|
52
52
|
def redirect_back_or_default(default)
|
@@ -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,9 +6,7 @@ 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.
|
@@ -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
|
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.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:
|
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.
|