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