mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Merge pull request #5796 from ErisDS/user-invite-val
Adds rudimentary validation to user invite
This commit is contained in:
commit
4ff23ec9f0
@ -1,8 +1,11 @@
|
||||
import Ember from 'ember';
|
||||
import ValidationEngine from 'ghost/mixins/validation-engine';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
export default Ember.Controller.extend(ValidationEngine, {
|
||||
notifications: Ember.inject.service(),
|
||||
|
||||
validationType: 'signup',
|
||||
|
||||
role: null,
|
||||
authorRole: null,
|
||||
|
||||
@ -42,13 +45,13 @@ export default Ember.Controller.extend({
|
||||
confirmAccept: function () {
|
||||
var email = this.get('email'),
|
||||
role = this.get('role'),
|
||||
validationErrors = this.get('errors.messages'),
|
||||
self = this,
|
||||
newUser;
|
||||
|
||||
// reset the form and close the modal
|
||||
self.set('email', '');
|
||||
self.set('role', self.get('authorRole'));
|
||||
self.send('closeModal');
|
||||
this.set('email', '');
|
||||
this.set('role', self.get('authorRole'));
|
||||
|
||||
this.store.find('user').then(function (result) {
|
||||
var invitedUser = result.findBy('email', email);
|
||||
@ -82,7 +85,13 @@ export default Ember.Controller.extend({
|
||||
// save is overridden in order to validate, we probably
|
||||
// want to use inline-validations here and only show an
|
||||
// alert if we have an actual error
|
||||
self.get('notifications').showErrors(errors);
|
||||
if (errors) {
|
||||
self.get('notifications').showErrors(errors);
|
||||
} else if (validationErrors) {
|
||||
self.get('notifications').showAlert(validationErrors.toString(), {type: 'error'});
|
||||
}
|
||||
}).finally(function () {
|
||||
self.get('errors').clear();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -46,10 +46,16 @@ var TeamUserRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
|
||||
model.rollback();
|
||||
}
|
||||
|
||||
model.get('errors').clear();
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
actions: {
|
||||
didTransition: function () {
|
||||
this.modelFor('team.user').get('errors').clear();
|
||||
},
|
||||
|
||||
save: function () {
|
||||
this.get('controller').send('save');
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
title="Invite a New User" confirm=confirm class="invite-new-user"}}
|
||||
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
{{#gh-form-group errors=errors hasValidated=hasValidated property="email"}}
|
||||
<label for="new-user-email">Email Address</label>
|
||||
{{input enter="confirmAccept" class="gh-input email" id="new-user-email" type="email" placeholder="Email Address" name="email" autofocus="autofocus"
|
||||
autocapitalize="off" autocorrect="off" value=email}}
|
||||
</div>
|
||||
{{gh-input enter="confirmAccept" class="email" id="new-user-email" type="email" placeholder="Email Address" name="email" autofocus="autofocus"
|
||||
autocapitalize="off" autocorrect="off" value=email focusOut=(action "validate" "email")}}
|
||||
{{gh-error-message errors=errors property="email"}}
|
||||
{{/gh-form-group}}
|
||||
|
||||
<div class="form-group for-select">
|
||||
<label for="new-user-role">Role</label>
|
||||
|
Loading…
Reference in New Issue
Block a user