authentication-zero 2.16.30 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c282c63840e3d6072f86c899f4a477296f2d5145317b715c00e2a434a2c2a565
|
4
|
+
data.tar.gz: 6f45065151e320e21a01c58a6daf2cf4101780428d6fd6d14341722aaec1bbd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ff1fc4f8822b6edaad54cd754b1b14ecfe89bfd6afb195942fce0974e3907852aea9a6fef643cffcd01351f992eaf3524bf0a92e773ff7ed97669de11ff0d6
|
7
|
+
data.tar.gz: c1d3fa6bc16f41f0826edd2121910ead50c01137cdbf42a7140dd1625eaadab5606678986022d28a9972ca1aef0669e7bb4ab2f1fa5dacdf2b130365963cd6f2
|
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
|
73
|
-
- The `Current.account` is set according to the url
|
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 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
|
+
- 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 `joins(:user).find_by_id...` in the `authenticate` method.
|
78
|
+
- Use `redirect_to "/#{user.account_id}"` after sign-in.
|
79
|
+
- Override `Current#user=` to also set the account, `super; self.account = user.account`.
|
80
|
+
- etc...
|
78
81
|
|
79
82
|
## Development
|
80
83
|
|
@@ -8,9 +8,9 @@ class AccountMiddleware
|
|
8
8
|
|
9
9
|
_, account_id, request_path = request.path.split("/", 3)
|
10
10
|
|
11
|
-
if
|
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
|
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.
|
28
|
+
Current.account = Account.find_by_id(account_id)
|
29
29
|
end
|
30
30
|
end
|
@@ -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
|
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.
|
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-
|
11
|
+
date: 2023-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|