mirror of
https://github.com/discourse/discourse.git
synced 2025-02-11 14:49:28 +08:00
![Régis Hanol](/assets/img/avatar_default.png)
- new "show-footer" mixins - converted most of the routes to ES6 - FIX: handling of "indexStream" in user pages There will now be a footer on all the following pages - /exception - /about - /latest - /new - /unread - /starred - /top - /categories - /c/:category - /c/:category/l/latest - /c/:category/l/new - /c/:category/l/unread - /c/:category/l/top - /t/:topic/:id - /groups/:name/members - /user/activity - /user/activity/topics - /user/activity/posts - /user/activity/replies - /user/activity/likes-given - /user/activity/likes-received - /user/activity/bookmarks - /user/activity/starred - /user/badges - /user/notifications - /user/flagged-posts - /user/deleted-posts - /user/private-messages - /user/private-messages/mine - /user/private-messages/unread - /user/invited - /user/:username/preferences - /faq (static pages) - /badges - /badges/:id/:badge
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|
import DiscourseController from 'discourse/controllers/controller';
|
|
|
|
export default DiscourseController.extend(ModalFunctionality, {
|
|
|
|
// You need a value in the field to submit it.
|
|
submitDisabled: function() {
|
|
return this.blank('accountEmailOrUsername') || this.get('disabled');
|
|
}.property('accountEmailOrUsername', 'disabled'),
|
|
|
|
actions: {
|
|
submit: function() {
|
|
var self = this;
|
|
|
|
if (this.get('submitDisabled')) return false;
|
|
|
|
this.set('disabled', true);
|
|
|
|
var success = function(data) {
|
|
// don't tell people what happened, this keeps it more secure (ensure same on server)
|
|
var escaped = Handlebars.Utils.escapeExpression(self.get('accountEmailOrUsername'));
|
|
var isEmail = self.get('accountEmailOrUsername').match(/@/);
|
|
|
|
var key = 'forgot_password.complete_' + (isEmail ? 'email' : 'username');
|
|
var extraClass;
|
|
|
|
if (data.user_found === true) {
|
|
key += '_found';
|
|
}
|
|
|
|
if (data.user_found === false) {
|
|
key += '_not_found';
|
|
extraClass = 'error';
|
|
}
|
|
|
|
self.flash(I18n.t(key, {email: escaped, username: escaped}), extraClass);
|
|
};
|
|
|
|
var fail = function(e) {
|
|
self.flash(e.responseJSON.errors[0], 'error');
|
|
};
|
|
|
|
Discourse.ajax('/session/forgot_password', {
|
|
data: { login: this.get('accountEmailOrUsername') },
|
|
type: 'POST'
|
|
}).then(success, fail).finally(function(){
|
|
setTimeout(function(){
|
|
self.set('disabled',false);
|
|
}, 10*1000);
|
|
});
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
});
|