expired.js 821 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * expired.js
  3. *
  4. * A custom response that content-negotiates the current request to either:
  5. * • serve an HTML error page about the specified token being invalid or expired
  6. * • or send back 498 (Token Expired/Invalid) with no response body.
  7. *
  8. * Example usage:
  9. * ```
  10. * return res.expired();
  11. * ```
  12. *
  13. * Or with actions2:
  14. * ```
  15. * exits: {
  16. * badToken: {
  17. * description: 'Provided token was expired, invalid, or already used up.',
  18. * responseType: 'expired'
  19. * }
  20. * }
  21. * ```
  22. */
  23. module.exports = function expired() {
  24. var req = this.req;
  25. var res = this.res;
  26. sails.log.verbose('Ran custom response: res.expired()');
  27. if (req.wantsJSON) {
  28. return res.status(498).send('Token Expired/Invalid');
  29. }
  30. else {
  31. return res.status(498).view('498');
  32. }
  33. };