thecore_auth_commons 3.0.7 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/initializers/concern_user.rb +1 -9
- data/db/seeds.rb +1 -2
- metadata +2 -3
- data/db/migrate/20160209153533_add_access_token_to_user.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3ccd6b97ae712679baaee1d4efc1668af4dac8c5b274e1f8d5a3dd4a3390cf0
|
4
|
+
data.tar.gz: 926c41659cb41f08f6f7dae8dcf2f48a48749cbaad7bf58aa1bf19c2770d9af4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3899810844e5abbe770adefd9919837e3d2239b93ac4be5707c67f0135dd14c607d781335af09c6315c9f9466597111ce82981ba3458549cf770be68a25b31a8
|
7
|
+
data.tar.gz: f3ef98ce1fe31ea4b914a3abed4e2d89cd418473e5d795ee864dcce9e5a846d8cfdbc2ccd9ec60d4960763d7905b229778ecfc7762496e9e978392cdb38eafaa
|
@@ -1,14 +1,7 @@
|
|
1
1
|
module ThecoreAuthCommonsUserConcern
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
-
included do
|
5
|
-
before_validation on: :create do
|
6
|
-
# If the generated uuid is not already present, then create the user with the proposed uuid
|
7
|
-
# Otherwise, try to generate another one
|
8
|
-
begin
|
9
|
-
self.access_token = SecureRandom.uuid #urlsafe_base64(32)
|
10
|
-
end while ::User.exists?(access_token: self.access_token)
|
11
|
-
end
|
4
|
+
included do
|
12
5
|
# REFERENCES
|
13
6
|
has_many :role_users, dependent: :destroy, inverse_of: :user
|
14
7
|
has_many :roles, through: :role_users, inverse_of: :users
|
@@ -17,7 +10,6 @@ module ThecoreAuthCommonsUserConcern
|
|
17
10
|
validates :password, presence: true, on: :create
|
18
11
|
validates :password_confirmation, presence: true, on: :create
|
19
12
|
validate :check_password_and_confirmation_equal
|
20
|
-
validates :access_token, uniqueness: true
|
21
13
|
validates_each :admin do |record, attr, value|
|
22
14
|
# Don't want admin == false if the current user is the only admin
|
23
15
|
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
|
data/db/seeds.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
puts "Loading ThecoreAuthCommons seeds"
|
2
|
-
email = ENV["
|
2
|
+
email = "admin@#{ENV["BASE_DOMAIN"]}"
|
3
3
|
psswd = ENV["ADMIN_PASSWORD"].presence || "changeme"
|
4
4
|
|
5
5
|
unless User.where(admin: true).exists?
|
6
6
|
u = User.find_or_initialize_by(email: email)
|
7
7
|
u.username = "Administrator" if u.respond_to? :username=
|
8
8
|
u.password = u.password_confirmation = psswd
|
9
|
-
u.encrypted_access_token = User.new(:password => SecureRandom.uuid).encrypted_password
|
10
9
|
u.admin = true
|
11
10
|
u.save(validate: false)
|
12
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_auth_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -194,7 +194,6 @@ files:
|
|
194
194
|
- db/migrate/20160209153229_add_admin_to_user.rb
|
195
195
|
- db/migrate/20160209153326_add_lock_version_to_user.rb
|
196
196
|
- db/migrate/20160209153406_add_locked_to_user.rb
|
197
|
-
- db/migrate/20160209153533_add_access_token_to_user.rb
|
198
197
|
- db/migrate/20160209153811_create_roles.rb
|
199
198
|
- db/migrate/20160209153813_create_role_users.rb
|
200
199
|
- db/migrate/20160209153816_create_permissions_chain.rb
|