Fixes #1110 - Proper validation for the security labels.

This commit is contained in:
Murtuza Zabuawala 2016-06-06 18:07:12 +05:30 committed by Ashesh Vashi
parent e3ab4501d5
commit 9ed2530b1f
2 changed files with 25 additions and 15 deletions

View File

@ -95,7 +95,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
} }
},{ },{
id: 'spcuser', label:'{{ _('Owner') }}', cell: 'string', id: 'spcuser', label:'{{ _('Owner') }}', cell: 'string',
type: 'text', control: 'node-list-by-name', node: 'role' type: 'text', control: 'node-list-by-name', node: 'role',
select2: {allowClear: false}
},{ },{
id: 'acl', label: '{{ _('Privileges') }}', type: 'text', id: 'acl', label: '{{ _('Privileges') }}', type: 'text',
group: '{{ _('Security') }}', mode: ['properties'], disabled: true group: '{{ _('Security') }}', mode: ['properties'], disabled: true
@ -128,14 +129,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
errmsg = null, errmsg = null,
changedAttrs = this.sessAttrs, changedAttrs = this.sessAttrs,
msg = undefined; msg = undefined;
if (_.has(changedAttrs, 'name') && if (_.isUndefined(this.get('name'))
(_.isUndefined(this.get('name')) || String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
|| String(this.get('name')).replace(/^\s+|\s+$/g, '') == '')) {
msg = '{{ _('Name cannot be empty.') }}'; msg = '{{ _('Name cannot be empty.') }}';
this.errorModel.set('name', msg); this.errorModel.set('name', msg);
} else if (_.has(changedAttrs, 'spclocation') && } else if (_.isUndefined(this.get('spclocation'))
(_.isUndefined(this.get('spclocation')) || String(this.get('spclocation')).replace(/^\s+|\s+$/g, '') == '') {
|| String(this.get('spclocation')).replace(/^\s+|\s+$/g, '') == '')) {
msg = '{{ _('Location cannot be empty.') }}'; msg = '{{ _('Location cannot be empty.') }}';
this.errorModel.set('spclocation', msg); this.errorModel.set('spclocation', msg);
} else { } else {

View File

@ -20,15 +20,26 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
}], }],
validate: function() { validate: function() {
var err = {}, var err = {},
errmsg = null, errmsg = null;
data = this.toJSON(); this.errorModel.clear();
if (_.isUndefined(data.label) || if (_.isUndefined(this.get('provider')) ||
_.isNull(data.label) || _.isNull(this.get('provider')) ||
String(data.label).replace(/^\s+|\s+$/g, '') == '') { String(this.get('provider')).replace(/^\s+|\s+$/g, '') == '') {
return _("Please specify the value for all the security providers."); errmsg = '{{ _('Provider must be specified.') }}';
} this.errorModel.set('provider', errmsg);
return null; return errmsg;
}
if (_.isUndefined(this.get('label')) ||
_.isNull(this.get('label')) ||
String(this.get('label')).replace(/^\s+|\s+$/g, '') == '') {
errmsg = '{{ _('Label must be specified.') }}';
this.errorModel.set('label', errmsg);
return errmsg;
}
return null;
} }
}); });