forgot-password.page.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. parasails.registerPage('forgot-password', {
  2. // ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
  3. // ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
  4. // ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
  5. data: {
  6. // Main syncing/loading state for this page.
  7. syncing: false,
  8. // Form data
  9. formData: { /* … */ },
  10. // For tracking client-side validation errors in our form.
  11. // > Has property set to `true` for each invalid property in `formData`.
  12. formErrors: { /* … */ },
  13. // Server error state for the form
  14. cloudError: '',
  15. // Success state when form has been submitted
  16. cloudSuccess: false,
  17. },
  18. // ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
  19. // ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
  20. // ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
  21. beforeMount: function() {
  22. // Attach any initial data from the server.
  23. _.extend(this, SAILS_LOCALS);
  24. },
  25. mounted: function() {
  26. this.$focus('[autofocus]');
  27. },
  28. // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
  29. // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
  30. // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
  31. methods: {
  32. handleParsingForm: function() {
  33. // Clear out any pre-existing error messages.
  34. this.formErrors = {};
  35. var argins = this.formData;
  36. // Validate email:
  37. if(!argins.emailAddress) {
  38. this.formErrors.emailAddress = true;
  39. }
  40. // If there were any issues, they've already now been communicated to the user,
  41. // so simply return undefined. (This signifies that the submission should be
  42. // cancelled.)
  43. if (Object.keys(this.formErrors).length > 0) {
  44. return;
  45. }
  46. return argins;
  47. },
  48. submittedForm: function() {
  49. // If it worked, show the success message.
  50. this.cloudSuccess = true;
  51. },
  52. }
  53. });