authentication-zero 2.16.33 → 2.16.34

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: e0192b708d0a77022c0ebcca72d6a67cddf4037e5412b78692b14871d8055dc3
4
- data.tar.gz: beadfc9974865abbc3a64783d863e7ecffd9ed61d8134cb3db219ef9ab73b4a9
3
+ metadata.gz: a7a21585c929c9c8eee8d33a9709add052a69019db2d1cdec5dce194afc36c67
4
+ data.tar.gz: f4424c1a4166d1394fb1dc573edc0e8d90893d7e91347a9d6340de88d73f5d37
5
5
  SHA512:
6
- metadata.gz: c1b8a91979fa37f3486241f6ff40b726809bc196433bc67d3cb509b4adfc2afaf73afc4037a931237d6d0757d9f05a9b7a0e32e82a99d89baedd2ffb808d8b74
7
- data.tar.gz: 5c542b08d8a748b7b041849eb3bda327439ec9c07dd53d4eb62bafb4caf727f480b2a9c2e4001b6b26e7bb58d1a18e6deea3a2a7770b1d5f44cbd36ccf4b8913
6
+ metadata.gz: 45a0d2d68c6debd1c161a9c42d31263b0da1ac91ecf754f4675032e26abe208dc571f74a65b8a2a2109be3a6d66aa964a385ffd5d71c94de7c1d895b5a15e899
7
+ data.tar.gz: 131dbe9839a99f982cbb271474c93ac7b10f398f770bc4827a4deb22c1ec615d8a5d1869e8ef8eccad522a17b3736708d7fef3e907c98b1caaf8be27a966cebc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.16.33)
4
+ authentication-zero (2.16.34)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -66,15 +66,18 @@ Use `before_action :require_sudo` in controllers with sensitive information, it
66
66
 
67
67
  ### Tenantable
68
68
 
69
- Some artifacts are generated in the application, which makes it possible to implement row-level multitenancy applications. You should follow some steps to make it work.
69
+ Some artifacts are generated in the application, which makes it possible to implement row-level multitenancy applications. The `Current.account` is set using the current user account.
70
70
 
71
- - Add `account_id` to each scoped table using `rails g migration add_account_to_projects account:references`.
71
+ You should follow some steps to make it work:
72
+
73
+ - Add `account_id` to each scoped table. ex: `rails g migration add_account_to_projects account:references`.
72
74
  - Add `include AccountScoped` to scoped models. It set up the account relationship and default scope using the current account.
73
75
 
74
- #### Set Current.account through the URL. `http://myapp.com/:account_id`
76
+ Set `Current.account` through the URL. `http://myapp.com/:account_id`. (optional)
75
77
 
76
78
  - Add `require_relative "../lib/account_middleware"` to `config/application.rb`.
77
79
  - Add `config.middleware.use AccountMiddleware` to your application class.
80
+ - More customization is required...
78
81
 
79
82
  ## Development
80
83
 
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.16.33"
2
+ VERSION = "2.16.34"
3
3
  end
@@ -8,7 +8,7 @@ class AccountMiddleware
8
8
 
9
9
  _, account_id, request_path = request.path.split("/", 3)
10
10
 
11
- if identifier?(account_id)
11
+ if account_id !~ /\D/
12
12
  set_current_account(account_id)
13
13
 
14
14
  request.script_name = "/#{account_id}"
@@ -20,11 +20,7 @@ class AccountMiddleware
20
20
  end
21
21
 
22
22
  private
23
- def identifier?(value)
24
- Integer(value, exception: false) != nil
25
- end
26
-
27
23
  def set_current_account(account_id)
28
- Current.account = Account.find_by_id(account_id)
24
+ Current.account = Account.find(account_id)
29
25
  end
30
26
  end
@@ -1,3 +1,3 @@
1
1
  class Account < ApplicationRecord
2
- has_one :account, dependent: :destroy
2
+ has_one :user, dependent: :destroy
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentication-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.33
4
+ version: 2.16.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: