discourse/app/assets/javascripts/discourse/controllers/account-created-edit-email.js.es6

30 lines
775 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import { changeEmail } from "discourse/lib/user-activation";
import computed from "ember-addons/ember-computed-decorators";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Controller.extend({
accountCreated: null,
newEmail: null,
2018-06-15 23:03:24 +08:00
@computed("newEmail", "accountCreated.email")
submitDisabled(newEmail, currentEmail) {
return newEmail === currentEmail;
},
actions: {
changeEmail() {
2018-06-15 23:03:24 +08:00
const email = this.get("newEmail");
changeEmail({ email })
.then(() => {
this.set("accountCreated.email", email);
this.transitionToRoute("account-created.resent");
})
.catch(popupAjaxError);
},
cancel() {
2018-06-15 23:03:24 +08:00
this.transitionToRoute("account-created.index");
}
}
});