From e503424ca5ce259d3211fe5bed586b8e266ce45f Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Thu, 29 Feb 2024 12:04:19 +0100 Subject: [PATCH] feat(mellow-vue): replace calls to sails.inertia.render with inertia custom response and exit --- .../api/controllers/auth/view-check-email.js | 13 +++++++++---- .../controllers/auth/view-forgot-password.js | 6 ++++-- .../api/controllers/auth/view-link-expired.js | 6 ++++-- .../api/controllers/auth/view-login.js | 6 ++++-- .../api/controllers/auth/view-reset-password.js | 6 ++++-- .../api/controllers/auth/view-signup.js | 6 ++++-- .../api/controllers/auth/view-success.js | 17 +++++++++++------ .../mellow-vue/api/controllers/home/index.js | 8 ++++++-- .../api/controllers/user/view-profile.js | 6 ++++-- 9 files changed, 50 insertions(+), 24 deletions(-) diff --git a/templates/mellow-vue/api/controllers/auth/view-check-email.js b/templates/mellow-vue/api/controllers/auth/view-check-email.js index ad753995..891b9766 100644 --- a/templates/mellow-vue/api/controllers/auth/view-check-email.js +++ b/templates/mellow-vue/api/controllers/auth/view-check-email.js @@ -4,7 +4,9 @@ module.exports = { description: 'Display "Verify email" page.', exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function () { @@ -14,8 +16,11 @@ module.exports = { } else { message = `We sent an email verification link to ${this.req.session.userEmail}` } - return sails.inertia.render('check-email', { - message - }) + return { + page: 'check-email', + props: { + message + } + } } } diff --git a/templates/mellow-vue/api/controllers/auth/view-forgot-password.js b/templates/mellow-vue/api/controllers/auth/view-forgot-password.js index 53c019f1..d5896864 100644 --- a/templates/mellow-vue/api/controllers/auth/view-forgot-password.js +++ b/templates/mellow-vue/api/controllers/auth/view-forgot-password.js @@ -4,10 +4,12 @@ module.exports = { description: 'Display "Forgot password" page.', exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function () { - return sails.inertia.render('forgot-password') + return { page: 'forgot-password' } } } diff --git a/templates/mellow-vue/api/controllers/auth/view-link-expired.js b/templates/mellow-vue/api/controllers/auth/view-link-expired.js index 7792337f..a82cf1e3 100644 --- a/templates/mellow-vue/api/controllers/auth/view-link-expired.js +++ b/templates/mellow-vue/api/controllers/auth/view-link-expired.js @@ -4,10 +4,12 @@ module.exports = { description: 'Display "Link expired" page.', exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function () { - return sails.inertia.render('link-expired') + return { page: 'link-expired' } } } diff --git a/templates/mellow-vue/api/controllers/auth/view-login.js b/templates/mellow-vue/api/controllers/auth/view-login.js index 0ef59eb5..4f5838d1 100644 --- a/templates/mellow-vue/api/controllers/auth/view-login.js +++ b/templates/mellow-vue/api/controllers/auth/view-login.js @@ -4,10 +4,12 @@ module.exports = { description: 'Display "Login" page.', exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function () { - return sails.inertia.render('login') + return { page: 'login' } } } diff --git a/templates/mellow-vue/api/controllers/auth/view-reset-password.js b/templates/mellow-vue/api/controllers/auth/view-reset-password.js index 7ac0d42c..b773f6aa 100644 --- a/templates/mellow-vue/api/controllers/auth/view-reset-password.js +++ b/templates/mellow-vue/api/controllers/auth/view-reset-password.js @@ -10,7 +10,9 @@ module.exports = { } }, exits: { - success: {}, + success: { + responseType: 'inertia' + }, invalidOrExpiredToken: { responseType: 'expired', description: 'The provided token is expired, invalid, or already used up.' @@ -26,6 +28,6 @@ module.exports = { if (!user || user.passwordResetTokenExpiresAt <= Date.now()) { throw 'invalidOrExpiredToken' } - return sails.inertia.render('reset-password', { token }) + return { page: 'reset-password', props: { token } } } } diff --git a/templates/mellow-vue/api/controllers/auth/view-signup.js b/templates/mellow-vue/api/controllers/auth/view-signup.js index d9c845af..7d55fef4 100644 --- a/templates/mellow-vue/api/controllers/auth/view-signup.js +++ b/templates/mellow-vue/api/controllers/auth/view-signup.js @@ -3,10 +3,12 @@ module.exports = { description: 'Display "Signup" page.', exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function () { - return sails.inertia.render('signup') + return { page: 'signup' } } } diff --git a/templates/mellow-vue/api/controllers/auth/view-success.js b/templates/mellow-vue/api/controllers/auth/view-success.js index b561b421..4f2c6a0b 100644 --- a/templates/mellow-vue/api/controllers/auth/view-success.js +++ b/templates/mellow-vue/api/controllers/auth/view-success.js @@ -8,7 +8,9 @@ module.exports = { } }, exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function ({ operation }) { @@ -24,10 +26,13 @@ module.exports = { message = 'Password has been successful reset' pageHeading = 'Password reset successful' } - return sails.inertia.render('success', { - pageTitle, - pageHeading, - message - }) + return { + page: 'success', + props: { + pageTitle, + pageHeading, + message + } + } } } diff --git a/templates/mellow-vue/api/controllers/home/index.js b/templates/mellow-vue/api/controllers/home/index.js index e0595cfe..93bdb1d5 100644 --- a/templates/mellow-vue/api/controllers/home/index.js +++ b/templates/mellow-vue/api/controllers/home/index.js @@ -5,9 +5,13 @@ module.exports = { inputs: {}, - exits: {}, + exits: { + success: { + responseType: 'inertia' + } + }, fn: async function () { - return sails.inertia.render('index') + return { page: 'index' } } } diff --git a/templates/mellow-vue/api/controllers/user/view-profile.js b/templates/mellow-vue/api/controllers/user/view-profile.js index f3dfd0bc..98d7d2ff 100644 --- a/templates/mellow-vue/api/controllers/user/view-profile.js +++ b/templates/mellow-vue/api/controllers/user/view-profile.js @@ -4,10 +4,12 @@ module.exports = { description: 'Display "Profile" page.', exits: { - success: {} + success: { + responseType: 'inertia' + } }, fn: async function () { - return sails.inertia.render('profile') + return { page: 'profile' } } }