2013-10-03 15:04:25 -04:00
|
|
|
define(function() {
|
|
|
|
|
var ResetPassword = {};
|
2013-05-29 12:17:44 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
ResetPassword.init = function() {
|
|
|
|
|
var inputEl = document.getElementById('email'),
|
|
|
|
|
errorEl = document.getElementById('error'),
|
|
|
|
|
errorTextEl = errorEl.querySelector('p');
|
|
|
|
|
|
|
|
|
|
document.getElementById('reset').onclick = function() {
|
|
|
|
|
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) {
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('user.reset.send', {
|
2013-10-03 15:04:25 -04:00
|
|
|
email: inputEl.value
|
2014-01-16 21:19:29 -05:00
|
|
|
}, function(err, data) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var submitEl = document.getElementById('reset');
|
|
|
|
|
|
|
|
|
|
jQuery('#error').hide();
|
|
|
|
|
jQuery('#success').show();
|
2014-01-16 23:46:08 -05:00
|
|
|
jQuery('#success p').html('An email has been dispatched to "' + inputEl.value + '" with instructions on setting a new password.');
|
2014-01-16 21:19:29 -05:00
|
|
|
inputEl.value = '';
|
2013-10-03 15:04:25 -04:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
jQuery('#success').hide();
|
|
|
|
|
jQuery(errorEl).show();
|
|
|
|
|
errorTextEl.innerHTML = 'Please enter a valid email';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ResetPassword;
|
|
|
|
|
});
|