mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Closes: https://github.com/fleetdm/confidential/issues/6199 Changes: - Updated view-new-license to redirect non-logged-in users to the /register page (it was previously doing this, but had a policy applied, so non-logged-in users were always redirected to the signup page.) - Updated the /register page to support a new input: `purchaseLicense`. If this query string is provided, the register page will redirect users who sign up to the /new-license page. - Updated the /login page to support a new input: `purchaseLicense`. If this query string is provided, the login page will redirect users who log in to the /new-license page. - Updated policies to bypass the is-logged-in policy for the /new-license page. - Updated the "get your license" link in the website nav menu to go to the /new-license page.
46 lines
1.1 KiB
JavaScript
Vendored
46 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: '/register?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};
|
|
|
|
}
|
|
|
|
|
|
};
|