parasails.registerPage('change-password', { // ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗ // ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣ // ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝ data: { // Main syncing/loading state for this page. syncing: false, // Form data formData: { /* … */ }, // For tracking client-side validation errors in our form. // > Has property set to `true` for each invalid property in `formData`. formErrors: { /* … */ }, // Server error state for the form cloudError: '', }, // ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗ // ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣ // ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝ beforeMount: function() { // Attach raw data exposed by the server. _.extend(this, SAILS_LOCALS); }, mounted: function() { this.$focus('[autofocus]'); }, // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗ // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ methods: { handleParsingForm: function() { // Clear out any pre-existing error messages. this.formErrors = {}; var argins = { password: this.formData.password }; // Validate password: if(!argins.password) { this.formErrors.password = true; } // Validate password confirmation: if(argins.password && argins.password !== this.formData.confirmPassword) { this.formErrors.confirmPassword = true; } // If there were any issues, they've already now been communicated to the user, // so simply return undefined. (This signifies that the submission should be // cancelled.) if (Object.keys(this.formErrors).length > 0) { return; } return argins; }, submittedForm: function() { // Redirect to the logged-in dashboard on success. // > (Note that we re-enable the syncing state here. This is on purpose-- // > to make sure the spinner stays there until the page navigation finishes.) this.syncing = true; window.location = '/account'; }, } });