minimalist_authentication 2.2.1 → 2.2.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b86110ca5e209864047e3c499a09401a264019ea2bd4311d3eb11e02ac95c29c
|
4
|
+
data.tar.gz: '0493e05bb52e0090890c785149bfb237309b2ad6e81988258f5fda308f8bf8bf'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eade9a93179f92c337ed21258d438861fbe70210d1a252dab6998fe10f49d18e0b6ddf250bef8bc6ebae69aa068e44bf00e366d4aeae4e9c4c55775402c21a8f
|
7
|
+
data.tar.gz: b1fcc6eb5d0dcd5bfcb8e1e740a72faff20c397f8ed9bc216a0eba343cddbd36457e2bf03aa09ec1fee51c6f82f429c97b7dfc6becdf4562b555d744074f5d21
|
@@ -17,7 +17,8 @@ module MinimalistAuthentication
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get_user_from_session
|
20
|
-
|
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,26 +19,35 @@ module MinimalistAuthentication
|
|
20
19
|
before_save :hash_password
|
21
20
|
|
22
21
|
# Email validations
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
-
scope :active,
|
40
|
+
scope :active, ->(state = true) { where(active: state) }
|
41
|
+
scope :inactive, -> { active(false) }
|
34
42
|
end
|
35
43
|
|
36
44
|
module ClassMethods
|
37
45
|
# Authenticates a user form the params provided. Expects a params hash with
|
38
|
-
# email or username and
|
46
|
+
# email or username and password keys.
|
39
47
|
# Params examples:
|
40
48
|
# { email: 'user@example.com', password: 'abc123' }
|
41
49
|
# { username: 'user', password: 'abc123' }
|
42
|
-
# Returns user upon successful
|
50
|
+
# Returns user upon successful authentication.
|
43
51
|
# Otherwise returns nil.
|
44
52
|
def authenticate(params)
|
45
53
|
# extract email or username and the associated value
|
@@ -65,6 +73,11 @@ module MinimalistAuthentication
|
|
65
73
|
active
|
66
74
|
end
|
67
75
|
|
76
|
+
# Returns true if the user is not active.
|
77
|
+
def inactive?
|
78
|
+
!active
|
79
|
+
end
|
80
|
+
|
68
81
|
# Return true if password matches the hashed_password.
|
69
82
|
# If successful checks for an outdated password_hash and updates if
|
70
83
|
# necessary.
|
@@ -107,7 +120,7 @@ module MinimalistAuthentication
|
|
107
120
|
Password.new(password_hash)
|
108
121
|
end
|
109
122
|
|
110
|
-
#
|
123
|
+
# Require password for active users that either do no have a password hash
|
111
124
|
# stored OR are attempting to set a new password. Set **password_required**
|
112
125
|
# to true to force validations even when the password field is blank.
|
113
126
|
def validate_password?
|
@@ -122,7 +135,7 @@ module MinimalistAuthentication
|
|
122
135
|
end
|
123
136
|
|
124
137
|
# Validate email presence for active users.
|
125
|
-
# Applications can turn
|
138
|
+
# Applications can turn off email presence validation by setting
|
126
139
|
# validate_email_presence configuration attribute to false.
|
127
140
|
def validate_email_presence?
|
128
141
|
MinimalistAuthentication.configuration.validate_email_presence && validate_email?
|
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.
|
4
|
+
version: 2.2.4
|
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: 2022-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -45,20 +45,6 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.1.3
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: loofah
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 2.3.1
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.3.1
|
62
48
|
- !ruby/object:Gem::Dependency
|
63
49
|
name: sqlite3
|
64
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
125
|
- !ruby/object:Gem::Version
|
140
126
|
version: '0'
|
141
127
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.3.9
|
143
129
|
signing_key:
|
144
130
|
specification_version: 4
|
145
131
|
summary: A Rails authentication plugin that takes a minimalist approach.
|