[auth]: Api key, basic authorization in main view
This commit is contained in:
@@ -3,52 +3,32 @@
|
||||
SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to global SwaggerUi
|
||||
|
||||
events:{
|
||||
'click #apikey_button' : 'toggleApiKeyContainer',
|
||||
'click #apply_api_key' : 'applyApiKey'
|
||||
'click .auth_submit_button' : 'applyApiKey'
|
||||
},
|
||||
|
||||
initialize: function(opts){
|
||||
template: Handlebars.templates.apikey_button_view,
|
||||
|
||||
initialize: function(opts) {
|
||||
this.options = opts || {};
|
||||
this.router = this.options.router;
|
||||
},
|
||||
|
||||
render: function(){
|
||||
var template = this.template();
|
||||
$(this.el).html(template(this.model));
|
||||
$(this.el).html(this.template(this.model));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
applyApiKey: function(){
|
||||
applyApiKey: function() {
|
||||
var keyAuth = new SwaggerClient.ApiKeyAuthorization(
|
||||
this.model.name,
|
||||
$('#input_apiKey_entry').val(),
|
||||
this.$('.input_apiKey_entry').val(),
|
||||
this.model.in
|
||||
);
|
||||
this.router.api.clientAuthorizations.add(this.model.name, keyAuth);
|
||||
this.router.load();
|
||||
$('#apikey_container').show();
|
||||
},
|
||||
|
||||
toggleApiKeyContainer: function(){
|
||||
if ($('#apikey_container').length) {
|
||||
|
||||
var elem = $('#apikey_container').first();
|
||||
|
||||
if (elem.is(':visible')){
|
||||
elem.hide();
|
||||
} else {
|
||||
|
||||
// hide others
|
||||
$('.auth_container').hide();
|
||||
elem.show();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
template: function(){
|
||||
return Handlebars.templates.apikey_button_view;
|
||||
//$('#apikey_container').show();
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user