view-homepage-or-redirect.js 649 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. module.exports = {
  2. friendlyName: 'View homepage or redirect',
  3. description: 'Display or redirect to the appropriate homepage, depending on login status.',
  4. exits: {
  5. success: {
  6. statusCode: 200,
  7. description: 'Requesting user is a guest, so show the public landing page.',
  8. viewTemplatePath: 'pages/homepage.ejs'
  9. },
  10. redirect: {
  11. responseType: 'redirect',
  12. description: 'Requesting user is logged in, so redirect to the internal welcome page.'
  13. },
  14. },
  15. fn: async function (inputs, exits) {
  16. if (this.req.me) {
  17. throw {redirect:'/welcome'};
  18. }
  19. return exits.success();
  20. }
  21. };