[auth] Fixed applying api key
This commit is contained in:
@@ -28,7 +28,6 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl
|
||||
);
|
||||
this.router.api.clientAuthorizations.add(this.model.name, keyAuth);
|
||||
this.router.load();
|
||||
//$('#apikey_container').show();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -10,7 +10,10 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
||||
authBtn: Handlebars.templates.auth_button
|
||||
},
|
||||
|
||||
initialize: function(){},
|
||||
initialize: function(opts) {
|
||||
this.options = opts || {};
|
||||
this.router = this.options.router;
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.html(this.tpls.authBtn());
|
||||
@@ -22,7 +25,7 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
||||
var authsModel;
|
||||
e.preventDefault();
|
||||
|
||||
authsModel = {title: 'Please authorize', content: this.renderAuths()};
|
||||
authsModel = {title: 'Available authorizations', content: this.renderAuths()};
|
||||
|
||||
this.popup = new SwaggerUi.Views.PopupView({model: authsModel});
|
||||
this.popup.render();
|
||||
@@ -47,6 +50,6 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
||||
}
|
||||
}
|
||||
|
||||
return el.html();
|
||||
return el;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||
this.model.securityDefinitions = this.model.securityDefinitions || {};
|
||||
|
||||
if (this.model.securityDefinitions) {
|
||||
this.authView = new SwaggerUi.Views.AuthView({model: this.model.securityDefinitions});
|
||||
this.authView = new SwaggerUi.Views.AuthView({model: this.model.securityDefinitions, router: this.router});
|
||||
this.$('.authorize-wrapper').append(this.authView.render().el);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ SwaggerUi.Views.PopupView = Backbone.View.extend({
|
||||
template: Handlebars.templates.popup,
|
||||
className: 'api-popup-dialog',
|
||||
|
||||
selectors: {
|
||||
content: '.api-popup-content',
|
||||
main : '#swagger-ui-container'
|
||||
},
|
||||
|
||||
initialize: function(){},
|
||||
|
||||
render: function () {
|
||||
@@ -17,7 +22,8 @@ SwaggerUi.Views.PopupView = Backbone.View.extend({
|
||||
dh = $win.height();
|
||||
st = $win.scrollTop();
|
||||
this.$el.html(this.template(this.model));
|
||||
$(document.body).append(this.el);
|
||||
this.$(this.selectors.content).append(this.model.content);
|
||||
$(this.selectors.main).first().append(this.el);
|
||||
dlgWd = this.$el.outerWidth();
|
||||
dlgHt = this.$el.outerHeight();
|
||||
top = (dh -dlgHt)/2 + st;
|
||||
|
||||
Reference in New Issue
Block a user