organizations 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +9 -5
- data/lib/organizations/version.rb +1 -1
- data/lib/organizations/view_helpers.rb +19 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 41b5d77cf4271b72a242ed018982a20a62de1aa65be8b44aeb0a1bdca6ca095f
|
|
4
|
+
data.tar.gz: 47da19b07cb78b00d63e3c682389d3b9cce80c10860883af947d25fb75ad4fa1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21cd1f525064c45d471ec8a8e271ddb524aa21843130f2124c0e1b2f903aed5edfb8cbe0a3376f1d699983191eabfdada1304b391244ed65f5e1f7292420d693
|
|
7
|
+
data.tar.gz: f8b6512de051110d180d894a3e23c49f6b16f50b7bb81f0ba8f4d79257f79063ee345f23332d1d923bc3baff0f7feeac56f62f726594a4750a6b7b6522a57acc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [0.4.3] - 2026-03-19
|
|
2
|
+
|
|
3
|
+
- Added `can_view_billing?` and `can_manage_billing?` view helpers for billing permission checks
|
|
4
|
+
- Refactored `can_manage_organization?` and `can_invite_members?` to use shared permission predicate
|
|
5
|
+
- Fixed `pricing_plans` integration examples to use `current_pricing_plan` (effective plan API)
|
|
6
|
+
- Clarified that billing permissions are authorization checks only, not subscription state indicators
|
|
7
|
+
|
|
1
8
|
## [0.4.2] - 2026-03-19
|
|
2
9
|
|
|
3
10
|
- Added `should_create_personal_organization?` predicate as extension seam for conditional personal org creation
|
data/README.md
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
`organizations` adds organizations with members to any Rails app. It handles team invites, user memberships, roles, and permissions.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
<img src="docs/organizations-invitation-accept-create-account.webp" width="500" />
|
|
11
11
|
|
|
12
|
-
https://
|
|
12
|
+
**🎮 [Try the live demo →](https://organizations.rameerez.com)**
|
|
13
13
|
|
|
14
14
|
It's everything you need to turn a `User`-based app into a multi-tenant, `Organization`-based B2B SaaS (users belong in organizations, and organizations share resources and billing, etc.)
|
|
15
15
|
|
|
@@ -41,6 +41,8 @@ current_user.is_organization_owner? # => true
|
|
|
41
41
|
current_user.is_organization_admin? # => true (owners inherit admin permissions)
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
https://github.com/user-attachments/assets/2eddafe2-025b-4670-af9f-e0d5480508c5
|
|
45
|
+
|
|
44
46
|
## Installation
|
|
45
47
|
|
|
46
48
|
Add to your Gemfile:
|
|
@@ -166,7 +168,7 @@ end
|
|
|
166
168
|
|
|
167
169
|
> **Note:** This is an integration pattern, not built-in functionality. You implement the limit checks in your callbacks.
|
|
168
170
|
|
|
169
|
-
If you're using [`pricing_plans`](https://github.com/rameerez/pricing_plans), you can limit how many members an organization can have based on their
|
|
171
|
+
If you're using [`pricing_plans`](https://github.com/rameerez/pricing_plans), you can limit how many members an organization can have based on their effective pricing plan using callbacks:
|
|
170
172
|
|
|
171
173
|
```ruby
|
|
172
174
|
# config/initializers/pricing_plans.rb
|
|
@@ -186,7 +188,7 @@ Then hook into the `on_member_invited` callback to enforce limits. **This callba
|
|
|
186
188
|
Organizations.configure do |config|
|
|
187
189
|
config.on_member_invited do |ctx|
|
|
188
190
|
org = ctx.organization
|
|
189
|
-
limit = org.
|
|
191
|
+
limit = org.current_pricing_plan.limit_for(:organization_members)
|
|
190
192
|
|
|
191
193
|
if limit && org.member_count >= limit
|
|
192
194
|
raise Organizations::InvitationError, "Member limit reached. Please upgrade your plan."
|
|
@@ -434,6 +436,8 @@ class SettingsController < ApplicationController
|
|
|
434
436
|
end
|
|
435
437
|
```
|
|
436
438
|
|
|
439
|
+
`manage_billing` and `view_billing` are authorization checks only. They control who in the organization can access your billing UI, but they do not imply an active Stripe subscription or determine the effective pricing plan.
|
|
440
|
+
|
|
437
441
|
### Handling unauthorized access
|
|
438
442
|
|
|
439
443
|
Configure how unauthorized access is handled:
|
|
@@ -1215,7 +1219,7 @@ end
|
|
|
1215
1219
|
|
|
1216
1220
|
### Integrates with pricing_plans
|
|
1217
1221
|
|
|
1218
|
-
Enforce member limits based on pricing
|
|
1222
|
+
Enforce member limits based on the effective pricing plan using callbacks:
|
|
1219
1223
|
|
|
1220
1224
|
```ruby
|
|
1221
1225
|
# In your Organization model
|
|
@@ -213,10 +213,7 @@ module Organizations
|
|
|
213
213
|
# @param organization [Organizations::Organization] The organization
|
|
214
214
|
# @return [Boolean]
|
|
215
215
|
def can_manage_organization?(user, organization)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
role = user.role_in(organization)
|
|
219
|
-
role && Roles.has_permission?(role, :manage_settings)
|
|
216
|
+
user_has_permission_in_org?(user, organization, :manage_settings)
|
|
220
217
|
end
|
|
221
218
|
|
|
222
219
|
# Check if current user can invite members
|
|
@@ -225,10 +222,25 @@ module Organizations
|
|
|
225
222
|
# @param organization [Organizations::Organization] The organization
|
|
226
223
|
# @return [Boolean]
|
|
227
224
|
def can_invite_members?(user, organization)
|
|
228
|
-
|
|
225
|
+
user_has_permission_in_org?(user, organization, :invite_members)
|
|
226
|
+
end
|
|
229
227
|
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
# Check if current user can view billing information
|
|
229
|
+
# Uses permission-based check to respect custom role configurations
|
|
230
|
+
# @param user [User] The user
|
|
231
|
+
# @param organization [Organizations::Organization] The organization
|
|
232
|
+
# @return [Boolean]
|
|
233
|
+
def can_view_billing?(user, organization)
|
|
234
|
+
user_has_permission_in_org?(user, organization, :view_billing)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Check if current user can manage billing
|
|
238
|
+
# Uses permission-based check to respect custom role configurations
|
|
239
|
+
# @param user [User] The user
|
|
240
|
+
# @param organization [Organizations::Organization] The organization
|
|
241
|
+
# @return [Boolean]
|
|
242
|
+
def can_manage_billing?(user, organization)
|
|
243
|
+
user_has_permission_in_org?(user, organization, :manage_billing)
|
|
232
244
|
end
|
|
233
245
|
|
|
234
246
|
# Check if current user can remove a member
|