thecore_auth_commons 3.0.6 → 3.0.8
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 +1 -4
- data/config/initializers/after_initialize.rb +2 -2
- data/config/initializers/concern_user.rb +1 -9
- data/db/migrate/20160208110805_devise_create_users.rb +3 -3
- data/db/seeds.rb +0 -4
- 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: 75d0bbf1a944e7f52195db777f70851d15e322254269833c5f8ded7724830011
|
4
|
+
data.tar.gz: 41ca8475384a8f92f099b9c7d4280274bc03816b8adc11cc23a50e1ed595a067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95b8a2188480dd5beea0ea52d994bd57e1f4b7087b258cc554e21f3cef44db4399549aabfacb9cdbe3216b48a27a2af26482569bfb6d1e9883957ca72fd1329
|
7
|
+
data.tar.gz: b8f70c1756c9e9399ee1953ae4e47c34d81c299c4a2f5f1500c132c9360a0b2064f5a7f8792fb374630b56e77cb10cc843d14d30cbf1e14da88e2ed150f03d0e
|
data/app/models/user.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
1
|
class User < ApplicationRecord
|
2
|
-
|
3
|
-
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
4
|
-
devise :database_authenticatable, :registerable,
|
5
|
-
:recoverable, :rememberable, :validatable
|
2
|
+
devise :database_authenticatable, :rememberable, :validatable
|
6
3
|
end
|
@@ -6,7 +6,7 @@ Rails.application.configure do
|
|
6
6
|
|
7
7
|
Ability.send(:include, ThecoreAuthCommonsCanCanCanConcern)
|
8
8
|
User.send(:include, ThecoreAuthCommonsUserConcern)
|
9
|
-
User.devise_modules.delete(:recoverable) if ThecoreSettings::Setting.where(ns: :devise, key: :recoverable).first.present? && ThecoreSettings::Setting.where(ns: :devise, key: :recoverable).first.raw == "disable"
|
10
|
-
User.devise_modules.delete(:registerable) if ThecoreSettings::Setting.where(ns: :devise, key: :registerable).first.present? && ThecoreSettings::Setting.where(ns: :devise, key: :registerable).first.raw == "disable"
|
9
|
+
# User.devise_modules.delete(:recoverable) if ThecoreSettings::Setting.where(ns: :devise, key: :recoverable).first.present? && ThecoreSettings::Setting.where(ns: :devise, key: :recoverable).first.raw == "disable"
|
10
|
+
# User.devise_modules.delete(:registerable) if ThecoreSettings::Setting.where(ns: :devise, key: :registerable).first.present? && ThecoreSettings::Setting.where(ns: :devise, key: :registerable).first.raw == "disable"
|
11
11
|
end
|
12
12
|
end
|
@@ -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
|
@@ -8,8 +8,8 @@ class DeviseCreateUsers < ActiveRecord::Migration[7.0]
|
|
8
8
|
t.string :encrypted_password, null: false, default: ""
|
9
9
|
|
10
10
|
## Recoverable
|
11
|
-
t.string :reset_password_token
|
12
|
-
t.datetime :reset_password_sent_at
|
11
|
+
# t.string :reset_password_token
|
12
|
+
# t.datetime :reset_password_sent_at
|
13
13
|
|
14
14
|
## Rememberable
|
15
15
|
t.datetime :remember_created_at
|
@@ -37,7 +37,7 @@ class DeviseCreateUsers < ActiveRecord::Migration[7.0]
|
|
37
37
|
end
|
38
38
|
|
39
39
|
add_index :users, :email, unique: true, if_not_exists: true
|
40
|
-
add_index :users, :reset_password_token, unique: true, if_not_exists: true
|
40
|
+
# add_index :users, :reset_password_token, unique: true, if_not_exists: true
|
41
41
|
# add_index :users, :confirmation_token, unique: true
|
42
42
|
# add_index :users, :unlock_token, unique: true
|
43
43
|
end
|
data/db/seeds.rb
CHANGED
@@ -6,7 +6,6 @@ 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
|
@@ -26,6 +25,3 @@ end
|
|
26
25
|
fill :predicates
|
27
26
|
fill :actions
|
28
27
|
fill :targets
|
29
|
-
|
30
|
-
ThecoreSettings::Setting.create(ns: :devise, key: :registerable, raw: "disable")
|
31
|
-
ThecoreSettings::Setting.create(ns: :devise, key: :recoverable, raw: "disable")
|
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.8
|
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
|