Skip to content

Commit

Permalink
feat(mellow-vue): replace calls to sails.inertia.render with inertia …
Browse files Browse the repository at this point in the history
…custom response and exit
  • Loading branch information
DominusKelvin committed Feb 29, 2024
1 parent fbf003b commit e503424
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 24 deletions.
13 changes: 9 additions & 4 deletions templates/mellow-vue/api/controllers/auth/view-check-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module.exports = {
description: 'Display "Verify email" page.',

exits: {
success: {}
success: {
responseType: 'inertia'
}
},

fn: async function () {
Expand All @@ -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
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}
6 changes: 4 additions & 2 deletions templates/mellow-vue/api/controllers/auth/view-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand All @@ -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 } }
}
}
6 changes: 4 additions & 2 deletions templates/mellow-vue/api/controllers/auth/view-signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}
17 changes: 11 additions & 6 deletions templates/mellow-vue/api/controllers/auth/view-success.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ module.exports = {
}
},
exits: {
success: {}
success: {
responseType: 'inertia'
}
},

fn: async function ({ operation }) {
Expand All @@ -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
}
}
}
}
8 changes: 6 additions & 2 deletions templates/mellow-vue/api/controllers/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ module.exports = {

inputs: {},

exits: {},
exits: {
success: {
responseType: 'inertia'
}
},

fn: async function () {
return sails.inertia.render('index')
return { page: 'index' }
}
}
6 changes: 4 additions & 2 deletions templates/mellow-vue/api/controllers/user/view-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}

0 comments on commit e503424

Please sign in to comment.