minimalist_authentication 2.1.5 → 2.2.3

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: da71f663f9018201e58575975d85f9956b7147993481c52faf412b4584d653a7
4
- data.tar.gz: bd7928830eb2d4f1cf4dfe9a0a4530b759794d9a1b6c643a4d7d249a92f7777a
3
+ metadata.gz: cda06c345d4fa37142558f9d0dbeaf836214efebc30d05d0a048fbe914ded344
4
+ data.tar.gz: 462cc4702b9a9c5d2c6311743faeb22647da2900cea5650908641026635e9fdf
5
5
  SHA512:
6
- metadata.gz: a7e0fb0718a42d7949f93a6ac8ce7ec47c4c4aef6c5221fd92b89f153e98d3ea51862a599a79da768f56772575026ca6a60a42e4d7f51dcf6c2b01358441d7df
7
- data.tar.gz: 3ec3e7a79116e8bcb1ef98a609a95d693be43aadc55283d1f71c65e3cfa57a798955eedff1acc0c3b004d13cafa8f87da65f57b9964f8575472f39cbf6438d28
6
+ metadata.gz: 22ee36a9560fff58c576faa9e11d5a17ebfdd920b84a64c2673affe0a0abe39c98d256aaaf261e988e8c720a3a420984658a92073050520345974bb888421851
7
+ data.tar.gz: 11150ad09e46ef906e1d5b2f47172b33a8608867f4e5686d5c9d63636155be3eff0eb16509d74a8dccdd3da98c2e5985a9bf40c253f463762a0d44dd9d0072be
data/README.md CHANGED
@@ -147,4 +147,4 @@ When the conversion is complete the **crypted_password**, **salt**, and
147
147
 
148
148
 
149
149
  ## License
150
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
150
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT)..
@@ -3,7 +3,7 @@ class EmailsController < ApplicationController
3
3
  end
4
4
 
5
5
  def update
6
- if current_user.update_attributes(user_params)
6
+ if current_user.update(user_params)
7
7
  redirect_to update_redirect_path, notice: 'Email successfully updated'
8
8
  else
9
9
  render :edit
@@ -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
@@ -20,9 +20,9 @@ module MinimalistAuthentication
20
20
  before_save :hash_password
21
21
 
22
22
  # Email validations
23
- validates_presence_of :email, if: :validate_email_presence?
24
- validates_uniqueness_of :email, allow_blank: true, if: :validate_email?
25
- validates_format_of :email, allow_blank: true, with: EMAIL_REGEX, if: :validate_email?
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?
26
26
 
27
27
  # Password validations
28
28
  validates_presence_of :password, if: :validate_password?
@@ -30,16 +30,17 @@ module MinimalistAuthentication
30
30
  validates_length_of :password, within: PASSWORD_MIN..PASSWORD_MAX, if: :validate_password?
31
31
 
32
32
  # Active scope
33
- scope :active, ->(active = true) { where active: active }
33
+ scope :active, ->(state = true) { where(active: state) }
34
+ scope :inactive, -> { active(false) }
34
35
  end
35
36
 
36
37
  module ClassMethods
37
38
  # Authenticates a user form the params provided. Expects a params hash with
38
- # email or username and passwod keys.
39
+ # email or username and password keys.
39
40
  # Params examples:
40
41
  # { email: 'user@example.com', password: 'abc123' }
41
42
  # { username: 'user', password: 'abc123' }
42
- # Returns user upon successful authentcation.
43
+ # Returns user upon successful authentication.
43
44
  # Otherwise returns nil.
44
45
  def authenticate(params)
45
46
  # extract email or username and the associated value
@@ -65,6 +66,11 @@ module MinimalistAuthentication
65
66
  active
66
67
  end
67
68
 
69
+ # Returns true if the user is not active.
70
+ def inactive?
71
+ !active
72
+ end
73
+
68
74
  # Return true if password matches the hashed_password.
69
75
  # If successful checks for an outdated password_hash and updates if
70
76
  # necessary.
@@ -107,7 +113,7 @@ module MinimalistAuthentication
107
113
  Password.new(password_hash)
108
114
  end
109
115
 
110
- # Requre password for active users that either do no have a password hash
116
+ # Require password for active users that either do no have a password hash
111
117
  # stored OR are attempting to set a new password. Set **password_required**
112
118
  # to true to force validations even when the password field is blank.
113
119
  def validate_password?
@@ -122,7 +128,7 @@ module MinimalistAuthentication
122
128
  end
123
129
 
124
130
  # Validate email presence for active users.
125
- # Applications can turn offf email presence validation by setting
131
+ # Applications can turn off email presence validation by setting
126
132
  # validate_email_presence configuration attribute to false.
127
133
  def validate_email_presence?
128
134
  MinimalistAuthentication.configuration.validate_email_presence && validate_email?
@@ -1,3 +1,3 @@
1
1
  module MinimalistAuthentication
2
- VERSION = '2.1.5'
2
+ VERSION = '2.2.3'
3
3
  end
metadata CHANGED
@@ -1,28 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimalist_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Baldwin
8
8
  - Brightways Learning
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-19 00:00:00.000000000 Z
12
+ date: 2021-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '5.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '5.0'
28
28
  - !ruby/object:Gem::Dependency
@@ -110,7 +110,7 @@ homepage: https://github.com/wwidea/minimalist_authentication
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -125,8 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.0.4
129
- signing_key:
128
+ rubygems_version: 3.2.26
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: A Rails authentication plugin that takes a minimalist approach.
132
132
  test_files: []