From bbc4fd0ebff4c1db6e7fa8b3188d0e40d80f0d44 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 17 Apr 2024 13:28:02 -0500 Subject: [PATCH] Website: Add redirect for users with a Fleet Premium subscription. (#18374) Closes: #18373 Changes: - Updated `view-start` to redirect users who have already purchased a license to their customer dashboard --- website/api/controllers/view-start.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/website/api/controllers/view-start.js b/website/api/controllers/view-start.js index a18fdd8ed1..b342c01855 100644 --- a/website/api/controllers/view-start.js +++ b/website/api/controllers/view-start.js @@ -11,12 +11,20 @@ module.exports = { success: { viewTemplatePath: 'pages/start' + }, + redirect: { + description: 'The requesting user already has a Fleet Premium subscription.', + responseType: 'redirect', } - }, fn: async function () { + // 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'}; + } if(this.req.me.lastSubmittedGetStartedQuestionnaireStep && !_.isEmpty(this.req.me.getStartedQuestionnaireAnswers)){ let currentStep = this.req.me.lastSubmittedGetStartedQuestionnaireStep; let previouslyAnsweredQuestions = this.req.me.getStartedQuestionnaireAnswers;