Merge pull request #2176 from trustpilot/make-oauth-scopes-optional

Make oauth2 scopes optional
This commit is contained in:
Ron
2016-06-13 10:22:00 -07:00
committed by GitHub

View File

@@ -21,12 +21,22 @@ SwaggerUi.Models.Oauth2Model = Backbone.Model.extend({
},
validate: function () {
var valid = _.findIndex(this.get('scopes'), function (o) {
return o.checked === true;
}) > -1;
var valid = false;
var scp = this.get('scopes');
var idx = _.findIndex(scp, function (o) {
return o.checked === true;
});
this.set('valid', valid);
if(scp.length > 0 && idx >= 0) {
valid = true;
}
return valid;
if(scp.length === 0) {
valid = true;
}
this.set('valid', valid);
return valid;
}
});