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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b1e66ae2f5c7db756eb318d707b5b876f9fcebe16f63b8026dc4da70ef61df9
4
- data.tar.gz: ad094777a2932128c522f0ec3a17d53e956dd501c88f4564c9fa9d4b34bdff99
3
+ metadata.gz: 75d0bbf1a944e7f52195db777f70851d15e322254269833c5f8ded7724830011
4
+ data.tar.gz: 41ca8475384a8f92f099b9c7d4280274bc03816b8adc11cc23a50e1ed595a067
5
5
  SHA512:
6
- metadata.gz: 29cc422294cf41c00c2ac56f9184cf3170aa7d96b5681aa7ae16ac9ea988f0d0710f7995a123435582493c05bb1ae5bfef9d750b61b4b76272b2b0c212c06a5d
7
- data.tar.gz: 1f8672bbf766fa896c8fe7b551830d9f5babc26c3626269e1cd74a9ff4b37aa282f88c0e58366db7df049947a449de7d8031698a9c64de0241ef138850bdc0e7
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
- # Include default devise modules. Others available are:
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.6
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 00:00:00.000000000 Z
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
@@ -1,5 +0,0 @@
1
- class AddAccessTokenToUser < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :users, :encrypted_access_token, :string, if_not_exists: true
4
- end
5
- end