authentication-zero 2.16.31 → 2.16.32

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: 8bff3de0a9b6c8fb09557b580d1f7bc3b9be99f71aadeb4e84d080be2ae022da
4
- data.tar.gz: f014555758b4bc5d8c5c4f3b7a7eeb3aef9790ef5d0726b56d20ed59e7c2a32c
3
+ metadata.gz: c282c63840e3d6072f86c899f4a477296f2d5145317b715c00e2a434a2c2a565
4
+ data.tar.gz: 6f45065151e320e21a01c58a6daf2cf4101780428d6fd6d14341722aaec1bbd1
5
5
  SHA512:
6
- metadata.gz: d48574ced8a36ac0e2ddb342176558b084f5bf892cf2cce8d8d96ee7183d59850bd170154c76cd6b1092a52bf6184b85353b592c9c395e5139a3536ac5e38468
7
- data.tar.gz: 83079c90bdee50d97ffb2f9c89dad298491363568784792ca1012683ccca5f4f3203e0eb424a92f61c8c18ffc7783bc252f5c93338fa931fbefc2015682bc323
6
+ metadata.gz: 25ff1fc4f8822b6edaad54cd754b1b14ecfe89bfd6afb195942fce0974e3907852aea9a6fef643cffcd01351f992eaf3524bf0a92e773ff7ed97669de11ff0d6
7
+ data.tar.gz: c1d3fa6bc16f41f0826edd2121910ead50c01137cdbf42a7140dd1625eaadab5606678986022d28a9972ca1aef0669e7bb4ab2f1fa5dacdf2b130365963cd6f2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.16.31)
4
+ authentication-zero (2.16.32)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -68,15 +68,15 @@ Use `before_action :require_sudo` in controllers with sensitive information, it
68
68
 
69
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.
70
70
 
71
- - Add `account_id` to each scoped table using `rails g migration add_account_to_projects account:references`
72
- - Add `include AccountScoped` to scoped models. It set up the relationship with the account and default scope using the current account
73
- - The `Current.account` is set according to the url ex: `http://mywebsite.com/1234/projects`
71
+ - Add `account_id` to each scoped table using `rails g migration add_account_to_projects account:references`.
72
+ - Add `include AccountScoped` to scoped models. It set up the account relationship and default scope using the current account.
73
+ - The `Current.account` is set according to the url. `http://mywebsite.com/1234/projects`.
74
74
  - You should customize the authentication flow yourself, it means:
75
- - Add `account_id` to your users table using `rails g migration add_account_to_users account:references`
76
- - Add `include AccountScoped` to your user model
77
- - Use `Session.joins(:user).find_by_id` on `ApplicationController#authenticate`
75
+ - Add `account_id` to your users table using `rails g migration add_account_to_users account:references`.
76
+ - Add `include AccountScoped` to your user model.
77
+ - Use `joins(:user).find_by_id...` in the `authenticate` method.
78
78
  - Use `redirect_to "/#{user.account_id}"` after sign-in.
79
- - Override `Current#user=` to also set the account using `super; self.account = user.account`
79
+ - Override `Current#user=` to also set the account, `super; self.account = user.account`.
80
80
  - etc...
81
81
 
82
82
  ## Development
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.16.31"
2
+ VERSION = "2.16.32"
3
3
  end
@@ -8,9 +8,9 @@ class AccountMiddleware
8
8
 
9
9
  _, account_id, request_path = request.path.split("/", 3)
10
10
 
11
- if is_number?(account_id)
11
+ if identifier?(account_id)
12
12
  set_current_account(account_id)
13
-
13
+
14
14
  request.script_name = "/#{account_id}"
15
15
  request.path_info = "/#{request_path}"
16
16
  @app.call(request.env)
@@ -20,11 +20,11 @@ class AccountMiddleware
20
20
  end
21
21
 
22
22
  private
23
- def is_number?(value)
24
- Integer(value, exception: false)
23
+ def identifier?(value)
24
+ Integer(value, exception: false) != nil
25
25
  end
26
26
 
27
27
  def set_current_account(account_id)
28
- Current.account = Account.find(account_id)
28
+ Current.account = Account.find_by_id(account_id)
29
29
  end
30
30
  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.31
4
+ version: 2.16.32
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-01 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: