@simplelayer/graniteer-core 0.3.13 → 0.3.14
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.
|
@@ -207,6 +207,10 @@ export async function handle(req, config) {
|
|
|
207
207
|
let provisionOk = false;
|
|
208
208
|
let provisionUnifiUserId;
|
|
209
209
|
let provisionPin;
|
|
210
|
+
// WiFi voucher minted by ftw-middleware (best-effort; absent when guest WiFi
|
|
211
|
+
// is disabled or the mint failed). Before 0.3.14 this was dropped here, so
|
|
212
|
+
// the voucher existed in UniFi but was never recorded or surfaced.
|
|
213
|
+
let wifiVoucher;
|
|
210
214
|
let provisionErrorCode;
|
|
211
215
|
const trialHmacSecret = Deno.env.get('TRIAL_HMAC_SECRET');
|
|
212
216
|
if (!trialHmacSecret) {
|
|
@@ -270,6 +274,14 @@ export async function handle(req, config) {
|
|
|
270
274
|
? provisionParsed.unifi_user_id : undefined;
|
|
271
275
|
const cred = provisionParsed?.credential;
|
|
272
276
|
provisionPin = cred && typeof cred.pin === 'string' ? cred.pin : undefined;
|
|
277
|
+
const wv = provisionParsed?.wifi_voucher;
|
|
278
|
+
if (wv && typeof wv.code_display === 'string' && wv.code_display) {
|
|
279
|
+
wifiVoucher = {
|
|
280
|
+
id: typeof wv.id === 'string' ? wv.id : '',
|
|
281
|
+
code_display: wv.code_display,
|
|
282
|
+
expires_minutes: typeof wv.expires_minutes === 'number' ? wv.expires_minutes : 0,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
273
285
|
}
|
|
274
286
|
}
|
|
275
287
|
}
|
|
@@ -286,6 +298,12 @@ export async function handle(req, config) {
|
|
|
286
298
|
else {
|
|
287
299
|
updatePayload.notes = 'Provisioned without a PIN — mint/set failed on ftw-middleware.';
|
|
288
300
|
}
|
|
301
|
+
if (wifiVoucher) {
|
|
302
|
+
if (wifiVoucher.id)
|
|
303
|
+
updatePayload.wifi_voucher_id = wifiVoucher.id;
|
|
304
|
+
// The voucher is scoped to the trial window; record the window end.
|
|
305
|
+
updatePayload.wifi_expires_at = grant.trial_end_at;
|
|
306
|
+
}
|
|
289
307
|
const { error: statusUpdateErr } = await admin.from('trial_grants').update(updatePayload).eq('id', grant.id);
|
|
290
308
|
if (statusUpdateErr) {
|
|
291
309
|
await logOps(admin, 'admin_request_trial_status_update_failed', { grant_id: grant.id, message: statusUpdateErr.message }, { severity: 'error' });
|
|
@@ -335,6 +353,9 @@ export async function handle(req, config) {
|
|
|
335
353
|
trial_end_at: grant.trial_end_at,
|
|
336
354
|
status: finalStatus,
|
|
337
355
|
...(credential ? { credential } : {}),
|
|
356
|
+
...(wifiVoucher && provisionOk
|
|
357
|
+
? { wifi_voucher: { code_display: wifiVoucher.code_display, expires_minutes: wifiVoucher.expires_minutes } }
|
|
358
|
+
: {}),
|
|
338
359
|
...(provisioningErrorForResponse ? { provisioning_error: provisioningErrorForResponse } : {}),
|
|
339
360
|
});
|
|
340
361
|
}
|