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";
|
2017-05-03 03:57:55 +08:00
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
|
|
|
accountCreated: null,
|
|
|
|
newEmail: null,
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@computed("newEmail", "accountCreated.email")
|
2017-05-03 03:57:55 +08:00
|
|
|
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);
|
2017-05-03 03:57:55 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
cancel() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.transitionToRoute("account-created.index");
|
2017-05-03 03:57:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|