@franzzemen/brokenstock-shell 0.1.2 → 0.2.0
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.
|
@@ -116,12 +116,28 @@ class AuthenticationService {
|
|
|
116
116
|
return this.authenticated() && roleNames.some(r => this.userSession()?.roles.includes(r) === true);
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
119
|
+
* Is this BOOLEAN feature granted and on? e.g. `hasFeature('real-time')`.
|
|
120
|
+
*
|
|
121
|
+
* Strictly `=== true`, matching the back end's `hasFeature`. It used to be
|
|
122
|
+
* `!!this.features()[slug]`, which is NOT a valid entitlement test now that `0` is
|
|
123
|
+
* a real state: `Features` has FOUR states and truthiness collapses two of them.
|
|
124
|
+
*
|
|
125
|
+
* - key absent → not granted (an upsell)
|
|
126
|
+
* - `0` → granted, ZERO allowance (a limit — a different product, and
|
|
127
|
+
* FALSY, so `!!` reported it as "not in your plan")
|
|
128
|
+
* - `true` → granted, unlimited
|
|
129
|
+
* - `number`>0 → granted with that limit
|
|
130
|
+
*
|
|
131
|
+
* It also matters in the other direction: `!!` passed on any positive number, so a
|
|
132
|
+
* boolean slug misconfigured with a numeric value would show the affordance while
|
|
133
|
+
* the BE — which requires exactly `true` — refused every call behind it. The user
|
|
134
|
+
* sees the door and cannot open it.
|
|
135
|
+
*
|
|
136
|
+
* For QUANTITY features use {@link featureValue} and compare the limit yourself;
|
|
137
|
+
* this returns false for every numeric grant, including a valid one.
|
|
122
138
|
*/
|
|
123
139
|
hasFeature(slug) {
|
|
124
|
-
return this.authenticated() &&
|
|
140
|
+
return this.authenticated() && this.features()[slug] === true;
|
|
125
141
|
}
|
|
126
142
|
/** Raw plan-feature value (`true` for boolean grants, the numeric limit for quantity features, else undefined). */
|
|
127
143
|
featureValue(slug) {
|