minimalist_authentication 2.5.1 → 2.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d59f6a8045fd0f25d5e142e38c5080a084c1d7df63963fdb9e6fa161bd3516b
4
- data.tar.gz: 28cbe52a31186ed03df8d988474d2d7419c6ba19dc678608a0d2502b698e30b5
3
+ metadata.gz: d31aea6a71210e6ef2811dd5ea7d4f11654ff06cb3c5f92ace5ed00dd7d68d30
4
+ data.tar.gz: 1cb2c601a6effedef5bdc61960c7e08d7947083c4f755646b92c188c50e0a96f
5
5
  SHA512:
6
- metadata.gz: 3affcfacdbe213d469c484c0759a5038a90d99afea3d869db514e5ddc47575459a8c5b678aeb9259c008a5d1b89b89247eac9887d92de4812bd3f3825c1d40d6
7
- data.tar.gz: 9a60f4023d3c414817f2a514e135d2e23865c478f8d94f2aab41f5b83f31300f9ea403e845c27014fdd659abc632ac77963924ed9f51e3fdf1f85d58a62e7883
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
@@ -46,7 +46,7 @@ module MinimalistAuthentication
46
46
  end
47
47
 
48
48
  def store_location
49
- session["return_to"] = request.fullpath
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).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.1"
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.1
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-07-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.