fleet/website/api/controllers/view-fleetctl-preview.js
Eric a90e26e217
Website: Update /try-fleet redirect (#28427)
Closes: #28364

Changes:
- Updated the /try-fleet page to redirect logged-out users to the
/register page
- Updated the signup and login forms to redirect users to the try-fleet
page (if they navigated it that page before signing up/logging in)
2025-04-21 18:22:49 -05:00

59 lines
1.2 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View fleetctl preview',
description: 'Display "fleetctl preview" page.',
inputs: {
start: {
type: 'boolean',
description: 'A boolean flag that will hide the "next steps" buttons on the page if set to true',
defaultsTo: false,
}
},
exits: {
success: {
viewTemplatePath: 'pages/fleetctl-preview'
},
redirect: {
description: 'The requesting user is not logged in.',
responseType: 'redirect'
},
},
fn: async function ({start}) {
if(!this.req.me) {
throw {redirect: '/register#tryfleet'};
}
let trialLicenseKey;
// Check to see if this user has a Fleet premium trial license key.
let userHasTrialLicense = this.req.me.fleetPremiumTrialLicenseKey;
let userHasExpiredTrialLicense = false;
if(userHasTrialLicense) {
if(this.req.me.fleetPremiumTrialLicenseKeyExpiresAt < Date.now()) {
userHasExpiredTrialLicense = true;
}
trialLicenseKey = this.req.me.fleetPremiumTrialLicenseKey;
} else {
trialLicenseKey = '';
}
// Respond with view.
return {
hideNextStepsButtons: start,
trialLicenseKey,
userHasExpiredTrialLicense,
};
}
};