authentication-zero 2.16.30 → 2.16.31
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bff3de0a9b6c8fb09557b580d1f7bc3b9be99f71aadeb4e84d080be2ae022da
|
4
|
+
data.tar.gz: f014555758b4bc5d8c5c4f3b7a7eeb3aef9790ef5d0726b56d20ed59e7c2a32c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48574ced8a36ac0e2ddb342176558b084f5bf892cf2cce8d8d96ee7183d59850bd170154c76cd6b1092a52bf6184b85353b592c9c395e5139a3536ac5e38468
|
7
|
+
data.tar.gz: 83079c90bdee50d97ffb2f9c89dad298491363568784792ca1012683ccca5f4f3203e0eb424a92f61c8c18ffc7783bc252f5c93338fa931fbefc2015682bc323
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -68,13 +68,16 @@ 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
|
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
|
74
|
-
- You should customize the
|
75
|
-
- Add
|
76
|
-
-
|
77
|
-
-
|
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`
|
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`
|
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`
|
80
|
+
- etc...
|
78
81
|
|
79
82
|
## Development
|
80
83
|
|
@@ -2,10 +2,7 @@ module AccountScoped
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
belongs_to :account
|
6
|
-
|
7
|
-
default_scope do
|
8
|
-
where(account: Current.account || raise("You must set an account"))
|
9
|
-
end
|
5
|
+
belongs_to :account
|
6
|
+
default_scope { where account: Current.account }
|
10
7
|
end
|
11
8
|
end
|