thecore_auth_commons 2.3.4 → 2.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/user.rb +10 -1
- data/db/migrate/20210415154152_add_access_token_to_user.rb +5 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82192c45c694161639f30330e90570d71caa1e768cf294deb07fbd488291ebe5
|
4
|
+
data.tar.gz: 0b7719cc7d0ea1658a65904fbef7fadd940d57334db04f9794168ebdc9fde61f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e1885d41fda299bc79545e5fc038cd99478360f80c5a7d558dd217bfcc1a5d9daa1cf05eec09725959d8661795861c3380def8eec5e6b1ffce6b5b0cb09df5e
|
7
|
+
data.tar.gz: 962787a67397861a5849b440f5df1a67adaa50e534de7ff58e5af50740b2b099b387bfa2e1f1d8fb3fd33aa94c67f6e56257fe2ab110763b131e882d24a47e95
|
data/app/models/user.rb
CHANGED
@@ -10,7 +10,15 @@ class User < ApplicationRecord
|
|
10
10
|
# devise :rememberable
|
11
11
|
# devise :trackable
|
12
12
|
# devise :validatable
|
13
|
-
# devise :timeoutable, timeout_in: 30.minutes
|
13
|
+
# devise :timeoutable, timeout_in: 30.minutes
|
14
|
+
|
15
|
+
before_validation on: :create do
|
16
|
+
# If the generated uuid is not already present, then create the user with the proposed uuid
|
17
|
+
# Otherwise, try to generate another one
|
18
|
+
begin
|
19
|
+
self.access_token = SecureRandom.uuid #urlsafe_base64(32)
|
20
|
+
end while ::User.exists?(access_token: self.access_token)
|
21
|
+
end
|
14
22
|
# REFERENCES
|
15
23
|
has_many :role_users, dependent: :destroy, inverse_of: :user
|
16
24
|
has_many :roles, through: :role_users, inverse_of: :users
|
@@ -19,6 +27,7 @@ class User < ApplicationRecord
|
|
19
27
|
validates :password, presence: true, on: :create
|
20
28
|
validates :password_confirmation, presence: true, on: :create
|
21
29
|
validate :check_password_and_confirmation_equal
|
30
|
+
validates :access_token, uniqueness: true
|
22
31
|
validates_each :admin do |record, attr, value|
|
23
32
|
# Don't want admin == false if the current user is the only admin
|
24
33
|
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
|
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: 2.3.
|
4
|
+
version: 2.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- db/migrate/20200306153136_add_lock_version_to_role.rb
|
115
115
|
- db/migrate/20200516215346_add_locked_to_user.rb
|
116
116
|
- db/migrate/20200518082821_create_permissions.rb
|
117
|
+
- db/migrate/20210415154152_add_access_token_to_user.rb
|
117
118
|
- db/seeds.rb
|
118
119
|
- lib/abilities/thecore_auth_commons.rb
|
119
120
|
- lib/tasks/thecore_auth_commons_tasks.rake
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
rubygems_version: 3.0.3
|
145
|
+
rubygems_version: 3.0.3.1
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: Common Auth methods and models to be used in thecore components.
|