Files
fleet/website/api/controllers/customers/view-new-license.js
T
Eric 75ffd8b12f Website: Update login/register flow, add Fleet UI background to /try and /login (#39290)
Closes: https://github.com/fleetdm/fleet/issues/36465
Closes: https://github.com/fleetdm/fleet/issues/36467
Related to: https://github.com/fleetdm/confidential/issues/14254

Changes:
- Updated "Try it yourself" links to go to the `/try` page (Which
redirects users who aren't logged in to the /login page)
- Removed the `<signup-modal>` and `<signup-button>` components
- Removed the route for the /register page, and added a redirect to go
to /login
- Updated the /login page to have the signup form, and to match the
latest wireframes
- Updated the /try page to have a fake Fleet UI as a background
(previously an image)
2026-02-10 12:32:49 -06:00

47 lines
1.1 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View new license',
description: 'Display "New license" page.',
exits: {
success: {
viewTemplatePath: 'pages/customers/new-license'
},
redirect: {
description: 'The requesting user already has a subscription, or does not exist',
responseType: 'redirect',
}
},
fn: async function () {
// if the user isn't logged in, we'll redirect them to the register page.
if (!this.req.me) {
throw {redirect: '/login#purchaseLicense'};
}
// If the user is a super admin, we'll redirect them to the generate-license page.
if(this.req.me.isSuperAdmin) {
throw {redirect: '/admin/generate-license'};
}
// If the user has a license key, we'll redirect them to the customer dashboard.
let userHasExistingSubscription = await Subscription.findOne({user: this.req.me.id});
if (userHasExistingSubscription) {
throw {redirect: '/customers/dashboard?login'};
}
// Respond with view.
return { stripePublishableKey: sails.config.custom.stripePublishableKey};
}
};