When signing up with 3rd party verified email, don't allow changing email in the signup form. Add ability to cancel signup form, which clears its state.
This commit is contained in:
parent
3bba75b052
commit
769fb6a9d3
|
@ -18,6 +18,22 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
|
|||
rejectedPasswords: Em.A([]),
|
||||
prefilledUsername: null,
|
||||
|
||||
resetForm: function() {
|
||||
this.setProperties({
|
||||
accountName: '',
|
||||
accountEmail: '',
|
||||
accountUsername: '',
|
||||
accountPassword: '',
|
||||
authOptions: null,
|
||||
globalNicknameExists: false,
|
||||
complete: false,
|
||||
formSubmitted: false,
|
||||
rejectedEmails: Em.A([]),
|
||||
rejectedPasswords: Em.A([]),
|
||||
prefilledUsername: null
|
||||
});
|
||||
},
|
||||
|
||||
submitDisabled: function() {
|
||||
if (this.get('formSubmitted')) return true;
|
||||
if (this.get('nameValidation.failed')) return true;
|
||||
|
@ -37,7 +53,6 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
|
|||
|
||||
// Validate the name
|
||||
nameValidation: function() {
|
||||
|
||||
// If blank, fail without a reason
|
||||
if (this.blank('accountName')) return Discourse.InputValidation.create({ failed: true });
|
||||
|
||||
|
@ -101,6 +116,10 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
|
|||
});
|
||||
}.property('accountEmail', 'rejectedEmails.@each'),
|
||||
|
||||
emailValidated: function() {
|
||||
return this.get('authOptions.email') === this.get("accountEmail") && this.get('authOptions.email_valid');
|
||||
}.property('accountEmail', 'authOptions.email', 'authOptions.email_valid'),
|
||||
|
||||
prefillUsername: function() {
|
||||
if (this.get('prefilledUsername')) {
|
||||
// If username field has been filled automatically, and email field just changed,
|
||||
|
|
|
@ -12,6 +12,11 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
|
|||
authenticate: null,
|
||||
loggingIn: false,
|
||||
|
||||
resetForm: function() {
|
||||
this.set('authenticate', null);
|
||||
this.set('loggingIn', false);
|
||||
},
|
||||
|
||||
site: function() {
|
||||
return Discourse.Site.current();
|
||||
}.property(),
|
||||
|
@ -89,6 +94,12 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
|
|||
window.open(Discourse.getURL("/auth/" + name), "_blank",
|
||||
"menubar=no,status=no,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top);
|
||||
}
|
||||
},
|
||||
|
||||
createAccount: function() {
|
||||
var createAccountController = this.get('controllers.createAccount');
|
||||
createAccountController.resetForm();
|
||||
this.send('showCreateAccount');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ Discourse.ApplicationRoute = Em.Route.extend({
|
|||
actions: {
|
||||
showLogin: function() {
|
||||
Discourse.Route.showModal(this, 'login');
|
||||
this.controllerFor('login').resetForm();
|
||||
},
|
||||
|
||||
showCreateAccount: function() {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<tr class="input">
|
||||
<td><label for='new-account-email'>{{i18n user.email.title}}</label></td>
|
||||
<td>
|
||||
{{input value=accountEmail id="new-account-email"}}
|
||||
{{input value=accountEmail id="new-account-email" disabled=emailValidated}}
|
||||
{{inputTip validation=emailValidation}}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -70,6 +70,8 @@
|
|||
<button class='btn btn-large btn-primary' {{bindAttr disabled="submitDisabled"}} {{action createAccount}}>{{i18n create_account.title}}</button>
|
||||
{{#if formSubmitted}}
|
||||
<i class='fa fa-spinner fa-spin'></i>
|
||||
{{else}}
|
||||
<a {{action showLogin}}>{{i18n cancel}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/unless}}
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
{{#if showSignupLink}}
|
||||
{{i18n create_account.invite}}
|
||||
<a id="new-account-link" {{action showCreateAccount}}>
|
||||
<a id="new-account-link" {{action createAccount}}>
|
||||
{{i18n create_account.action}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue