Website: Create admin page for resetting Fleet Premium trials (#39980)

Changes:
- Added /admin/reset-trial, a page where website admins can reset local
Fleet Premium trials.
- Added a link to the reset trial page to the navigation on admin pages.
This commit is contained in:
Eric
2026-02-17 11:59:30 -06:00
committed by GitHub
parent aec1f1e304
commit b83aed2537
9 changed files with 252 additions and 1 deletions
@@ -0,0 +1,53 @@
module.exports = {
friendlyName: 'Reset one fleet premium local trial',
description: '',
inputs: {
emailAddress: { type: 'string', required: true, },
},
exits: {
success: {description: 'A user\'s Fleet premium trial was successfully reset.'},
userNotFound: {description: 'No user account was found using the provided email address.', responseType: 'notFound'},
trialTypeUnsupported: {description: 'This user has a Render trial.', responseType: 'badRequest'}
},
fn: async function ({emailAddress}) {
let thisUser = await User.findOne({emailAddress});
if(!thisUser) {
throw 'userNotFound';
}
if(thisUser.fleetPremiumTrialType === 'render trial') {
throw 'trialTypeUnsupported';
}
let thirtyDaysFromNowAt = Date.now() + (1000 * 60 * 60 * 24 * 30);
let newTrialLicenseKeyForThisUser = await sails.helpers.createLicenseKey.with({
numberOfHosts: 10,
organization: thisUser.organization,
expiresAt: thirtyDaysFromNowAt,
});
await User.updateOne({id: thisUser.id}).set({
fleetPremiumTrialLicenseKeyExpiresAt: thirtyDaysFromNowAt,
fleetPremiumTrialLicenseKey: newTrialLicenseKeyForThisUser,
});
// All done.
return;
}
};
+27
View File
@@ -0,0 +1,27 @@
module.exports = {
friendlyName: 'View reset trial',
description: 'Display "Reset trial" page.',
exits: {
success: {
viewTemplatePath: 'pages/admin/reset-trial'
}
},
fn: async function () {
// Respond with view.
return {};
}
};