2024-03-14 15:28:23 +00:00
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
friendlyName: 'View start',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
description: 'Display "Start" page.',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exits: {
|
|
|
|
|
|
|
|
|
|
success: {
|
|
|
|
|
viewTemplatePath: 'pages/start'
|
2024-04-17 18:28:02 +00:00
|
|
|
},
|
|
|
|
|
redirect: {
|
|
|
|
|
description: 'The requesting user already has a Fleet Premium subscription.',
|
|
|
|
|
responseType: 'redirect',
|
2024-03-14 15:28:23 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn: async function () {
|
2024-04-17 18:28:02 +00:00
|
|
|
// 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'};
|
|
|
|
|
}
|
2024-04-19 15:10:41 +00:00
|
|
|
if(this.req.me.isSuperAdmin){
|
|
|
|
|
throw {redirect: '/admin/generate-license'};
|
|
|
|
|
}
|
2024-04-04 16:13:53 +00:00
|
|
|
if(this.req.me.lastSubmittedGetStartedQuestionnaireStep && !_.isEmpty(this.req.me.getStartedQuestionnaireAnswers)){
|
|
|
|
|
let currentStep = this.req.me.lastSubmittedGetStartedQuestionnaireStep;
|
|
|
|
|
let previouslyAnsweredQuestions = this.req.me.getStartedQuestionnaireAnswers;
|
|
|
|
|
// Respond with view.
|
|
|
|
|
return {currentStep, previouslyAnsweredQuestions};
|
|
|
|
|
} else {
|
|
|
|
|
// Respond with view.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-14 15:28:23 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|