minimalist_authentication 2.2.2 → 2.3.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: d04ae5c32012e31770d8993023ef3d68e109118249bd91031b0888bc06cc9c87
4
- data.tar.gz: f115956d42f256ddafd2f1328c688ba3a72a2e447a4bd34a182e1034d0df9d29
3
+ metadata.gz: bd72c9f17536ef24bfc7d134733d03a00f1c235d5708b01dc2d5f415a484a688
4
+ data.tar.gz: 0501ccbf2663bf59d5a18ebb45566de7e04739b48ebda46ce6f0a5efa5ff0c78
5
5
  SHA512:
6
- metadata.gz: 43a655bede1179250c8f43410b239a4ae23ca07a80a0e7c2e65f0903ea9bf07772565026dc7b254c116f42682572a305e7bcd21a35a1049bde548fb48adddb99
7
- data.tar.gz: dbf795a8be4b6fe6e6fc6f10b17f7d12587aa15db58232f4d3bd87c985ce4f7a9d43cbe5b8d9451b227524ce477597b8f0d1bec67e24e94d374f57e769923bf0
6
+ metadata.gz: a1bb394153abcb693310c2d78a0d75385730accf41296e0871a86f15522a37db365bf09b41f94e092f4ab50be37b26765c0d91f93b88fcee6555d8737c4c38ab
7
+ data.tar.gz: aa4b2745cb630582b9c86a42aead66bd12b3be68d14c64f13d99f8cbbbd50423fc9820ba76bf84093503d84746d7046bb3823e421c3dc9d764f13e130c94f9d2
@@ -15,16 +15,17 @@ class PasswordResetsController < ApplicationController
15
15
  MinimalistAuthenticationMailer.update_password(user).deliver_now
16
16
  end
17
17
  # always display notice even if the user was not found to prevent leaking user emails
18
- redirect_to new_session_path, notice: "Password reset instructions were mailed to #{email_params[:email]}"
18
+ redirect_to new_session_path, notice: "Password reset instructions were mailed to #{email}"
19
19
  end
20
20
 
21
21
  private
22
22
 
23
23
  def user
24
- @user ||= MinimalistAuthentication.configuration.user_model.active.email_verified.find_by(email_params)
24
+ return unless URI::MailTo::EMAIL_REGEXP.match?(email)
25
+ @user ||= MinimalistAuthentication.configuration.user_model.active.email_verified.find_by(email: email)
25
26
  end
26
27
 
27
- def email_params
28
- params.require(:user).permit(:email)
28
+ def email
29
+ params.require(:user).fetch(:email)
29
30
  end
30
31
  end
@@ -17,7 +17,8 @@ module MinimalistAuthentication
17
17
  end
18
18
 
19
19
  def get_user_from_session
20
- MinimalistAuthentication.configuration.user_model.find_by_id(session_user_id) if session_user_id
20
+ return unless session_user_id
21
+ MinimalistAuthentication.configuration.user_model.active.find_by(id: session_user_id)
21
22
  end
22
23
 
23
24
  def session_user_id
@@ -5,7 +5,6 @@ module MinimalistAuthentication
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  GUEST_USER_EMAIL = 'guest'
8
- EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
9
8
  PASSWORD_MIN = 8
10
9
  PASSWORD_MAX = 40
11
10
 
@@ -20,14 +19,22 @@ module MinimalistAuthentication
20
19
  before_save :hash_password
21
20
 
22
21
  # Email validations
23
- validates_presence_of :email, if: :validate_email_presence?
24
- validates_uniqueness_of :email, allow_blank: true, case_sensitive: false, if: :validate_email?
25
- validates_format_of :email, allow_blank: true, with: EMAIL_REGEX, if: :validate_email?
22
+ validates(
23
+ :email,
24
+ format: { allow_blank: true, with: URI::MailTo::EMAIL_REGEXP },
25
+ uniqueness: { allow_blank: true, case_sensitive: false, scope: :active },
26
+ if: :validate_email?
27
+ )
28
+ validates(:email, presence: true, if: :validate_email_presence?)
26
29
 
27
30
  # Password validations
28
- validates_presence_of :password, if: :validate_password?
29
- validates_confirmation_of :password, if: :validate_password?
30
- validates_length_of :password, within: PASSWORD_MIN..PASSWORD_MAX, if: :validate_password?
31
+ validates(
32
+ :password,
33
+ confirmation: true,
34
+ length: { within: PASSWORD_MIN..PASSWORD_MAX },
35
+ presence: true,
36
+ if: :validate_password?
37
+ )
31
38
 
32
39
  # Active scope
33
40
  scope :active, ->(state = true) { where(active: state) }
@@ -1,3 +1,3 @@
1
1
  module MinimalistAuthentication
2
- VERSION = '2.2.2'
2
+ VERSION = '2.3.0'
3
3
  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.2.2
4
+ version: 2.3.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: 2021-08-31 00:00:00.000000000 Z
12
+ date: 2022-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.2.26
128
+ rubygems_version: 3.3.9
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: A Rails authentication plugin that takes a minimalist approach.