thecore_auth_commons 3.2.2 → 3.3.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 +4 -4
- data/README.md +5 -0
- data/app/models/user.rb +2 -1
- data/config/initializers/after_initialize.rb +3 -0
- data/config/initializers/concern_user.rb +4 -0
- data/config/locales/en.thecore_auth_commons.yml +11 -0
- data/config/locales/it.thecore_auth_commons.yml +11 -0
- data/db/seeds.rb +1 -1
- data/lib/thecore_auth_commons/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8907d856764c6dd40d87e0ed599bc85b55f213dbb25a0b112d0aa90605bfbc4
|
4
|
+
data.tar.gz: 6d14fc2c60062b4c3a1d64f68e72e096ccc5059b3ac7c226667ca98d51c54d18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7760e5a2998c8fa4325f54ae9be8f8010c90c7df4b98272d8277da3252b2a80e2c230771a6fdbd17a1764797c5ed711b41103da36ef305efff2cd6f9125e0f9
|
7
|
+
data.tar.gz: c912d733c2160b9699abad8d76a339406eb82c398beedd9245204197e79dac35334901f42845f72251f76a7a438e9a41b49ab97c9e897b43b5ee84c11da259fe
|
data/README.md
CHANGED
@@ -1 +1,6 @@
|
|
1
1
|
This is part of Thecore framework: https://github.com/gabrieletassoni/thecore/tree/release/3
|
2
|
+
|
3
|
+
It exposes two Env vars to chage the behaviour of Devise at startup:
|
4
|
+
|
5
|
+
- MIN_PASSWORD_LENGTH: the minimum length of the password (default: 8)
|
6
|
+
- SESSION_TIMEOUT_IN_MINUTES: the session timeout in minutes (default: 30)
|
data/app/models/user.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
class User < ApplicationRecord
|
2
|
-
|
2
|
+
# Get the minimum password length from the Environemnt or set it to 8
|
3
|
+
devise :database_authenticatable, :rememberable, :trackable, :timeoutable, :validatable, password_length: ENV.fetch('MIN_PASSWORD_LENGTH', 8).to_i..128, timeout_in: ENV.fetch('SESSION_TIMEOUT_IN_MINUTES', 31).to_i.minutes
|
3
4
|
end
|
@@ -3,6 +3,9 @@ Rails.application.configure do
|
|
3
3
|
# In development be sure to load all the namespaces
|
4
4
|
# in order to have working reflection
|
5
5
|
Zeitwerk::Loader.eager_load_all if Rails.env.development?
|
6
|
+
|
7
|
+
# Devise.timeout_in = ENV.fetch('SESSION_TIMEOUT_IN_MINUTES', 31).to_i.minutes
|
8
|
+
# Devise.password_length = ENV.fetch('MIN_PASSWORD_LENGTH', 8).to_i..128
|
6
9
|
|
7
10
|
Ability.send(:include, ThecoreAuthCommonsCanCanCanConcern)
|
8
11
|
User.send(:include, ThecoreAuthCommonsUserConcern)
|
@@ -10,6 +10,10 @@ module ThecoreAuthCommonsUserConcern
|
|
10
10
|
validates :password, presence: true, on: :create
|
11
11
|
validates :password_confirmation, presence: true, on: :create
|
12
12
|
validate :check_password_and_confirmation_equal
|
13
|
+
validates_each :password do |record, attr, value|
|
14
|
+
# Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character or be blank
|
15
|
+
record.errors.add(attr, I18n.t("validation.errors.password_must_contain_uppercase_lowercase_number_special_character")) unless value.blank? || (value =~ /[A-Z]/ && value =~ /[a-z]/ && value =~ /[0-9]/ && value =~ /[^A-Za-z0-9]/)
|
16
|
+
end
|
13
17
|
validates_each :admin do |record, attr, value|
|
14
18
|
# Don't want admin == false if the current user is the only admin
|
15
19
|
record.errors.add(attr, I18n.t("validation.errors.cannot_unadmin_last_admin")) if record.admin_changed? && record.admin_was == true && User.where(admin: true).count == 1
|
@@ -1,4 +1,15 @@
|
|
1
1
|
en:
|
2
|
+
error:
|
3
|
+
messages:
|
4
|
+
password_requires_letters_and_numbers: "must contain at least one letter and one number"
|
5
|
+
password_requires_special_characters: "must contain at least one special character"
|
6
|
+
validation:
|
7
|
+
errors:
|
8
|
+
password_must_contain_uppercase_lowercase_number_special_character: "must contain at least one uppercase letter, one lowercase letter, one number and one special character"
|
9
|
+
cannot_unadmin_last_admin: "at least one user must be an administrator"
|
10
|
+
cannot_unlock_last_admin: "at least one user must be unlocked"
|
11
|
+
cannot_delete_last_admin: "at least one user must be an administrator"
|
12
|
+
cannot_delete_last_role: "at least one role must exist"
|
2
13
|
activerecord:
|
3
14
|
models:
|
4
15
|
user:
|
@@ -1,4 +1,15 @@
|
|
1
1
|
it:
|
2
|
+
error:
|
3
|
+
messages:
|
4
|
+
password_requires_letters_and_numbers: "deve contenere almeno una lettera e un numero"
|
5
|
+
password_requires_special_characters: "deve contenere almeno un carattere speciale"
|
6
|
+
validation:
|
7
|
+
errors:
|
8
|
+
password_must_contain_uppercase_lowercase_number_special_character: "deve contenere almeno una lettera maiuscola, una lettera minuscola, un numero e un carattere speciale"
|
9
|
+
cannot_unadmin_last_admin: "almeno un utente deve essere un amministratore"
|
10
|
+
cannot_unlock_last_admin: "almeno un utente deve essere sbloccato"
|
11
|
+
cannot_delete_last_admin: "almeno un utente deve essere un amministratore"
|
12
|
+
cannot_delete_last_role: "deve esistere almeno un ruolo"
|
2
13
|
activerecord:
|
3
14
|
models:
|
4
15
|
user:
|
data/db/seeds.rb
CHANGED
@@ -4,7 +4,7 @@ puts "Loading ThecoreAuthCommons seeds"
|
|
4
4
|
Zeitwerk::Loader.eager_load_all
|
5
5
|
|
6
6
|
email = "admin@#{ENV["BASE_DOMAIN"].presence || "example.com"}"
|
7
|
-
psswd = ENV["ADMIN_PASSWORD"].presence || "
|
7
|
+
psswd = ENV["ADMIN_PASSWORD"].presence || "Change#1"
|
8
8
|
|
9
9
|
unless User.where(admin: true).exists?
|
10
10
|
u = User.find_or_initialize_by(email: email)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_auth_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-12 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: devise
|
@@ -73,6 +72,9 @@ dependencies:
|
|
73
72
|
- - "~>"
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
version: '3.0'
|
75
|
+
- - ">"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.5
|
76
78
|
type: :runtime
|
77
79
|
prerelease: false
|
78
80
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,6 +82,9 @@ dependencies:
|
|
80
82
|
- - "~>"
|
81
83
|
- !ruby/object:Gem::Version
|
82
84
|
version: '3.0'
|
85
|
+
- - ">"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 3.0.5
|
83
88
|
- !ruby/object:Gem::Dependency
|
84
89
|
name: simplecov
|
85
90
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,7 +217,6 @@ metadata:
|
|
212
217
|
homepage_uri: https://github.com/gabrieletassoni/thecore_auth_commons
|
213
218
|
source_code_uri: https://github.com/gabrieletassoni/thecore_auth_commons
|
214
219
|
changelog_uri: https://github.com/gabrieletassoni/thecore_auth_commons/blob/master/CHANGELOG.md
|
215
|
-
post_install_message:
|
216
220
|
rdoc_options: []
|
217
221
|
require_paths:
|
218
222
|
- lib
|
@@ -227,8 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
231
|
- !ruby/object:Gem::Version
|
228
232
|
version: '0'
|
229
233
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
231
|
-
signing_key:
|
234
|
+
rubygems_version: 3.6.2
|
232
235
|
specification_version: 4
|
233
236
|
summary: Common Auth methods and models to be used in thecore components.
|
234
237
|
test_files: []
|