This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/forgot-password.js.es6

38 lines
1.1 KiB
JavaScript

/**
The modal for when the user has forgotten their password
@class ForgotPasswordController
@extends Discourse.Controller
@namespace Discourse
@uses Discourse.ModalFunctionality
@module Discourse
**/
export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
// You need a value in the field to submit it.
submitDisabled: function() {
return this.blank('accountEmailOrUsername');
}.property('accountEmailOrUsername'),
actions: {
submit: function() {
if (!this.get('accountEmailOrUsername')) return false;
Discourse.ajax("/session/forgot_password", {
data: { login: this.get('accountEmailOrUsername') },
type: 'POST'
});
// don't tell people what happened, this keeps it more secure (ensure same on server)
var escaped = Handlebars.Utils.escapeExpression(this.get('accountEmailOrUsername'));
if (this.get('accountEmailOrUsername').match(/@/)) {
this.flash(I18n.t('forgot_password.complete_email', {email: escaped}));
} else {
this.flash(I18n.t('forgot_password.complete_username', {username: escaped}));
}
return false;
}
}
});