[auth] moved logout buttons into authentication view
This commit is contained in:
7
dist/css/print.css
vendored
7
dist/css/print.css
vendored
@@ -1188,13 +1188,6 @@
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .logout__btn {
|
||||
padding-left: 15px;
|
||||
}
|
||||
.swagger-section .logout__btn:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .auth_container .basic_auth__title {
|
||||
color: #547f00;
|
||||
font-size: 1.2em;
|
||||
|
||||
7
dist/css/screen.css
vendored
7
dist/css/screen.css
vendored
@@ -1188,13 +1188,6 @@
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .logout__btn {
|
||||
padding-left: 15px;
|
||||
}
|
||||
.swagger-section .logout__btn:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .auth_container .basic_auth__title {
|
||||
color: #547f00;
|
||||
font-size: 1.2em;
|
||||
|
||||
8141
dist/swagger-ui.js
vendored
8141
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
20
dist/swagger-ui.min.js
vendored
20
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1188,13 +1188,6 @@
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .logout__btn {
|
||||
padding-left: 15px;
|
||||
}
|
||||
.swagger-section .logout__btn:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .auth_container .basic_auth__title {
|
||||
color: #547f00;
|
||||
font-size: 1.2em;
|
||||
|
||||
@@ -1188,13 +1188,6 @@
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .logout__btn {
|
||||
padding-left: 15px;
|
||||
}
|
||||
.swagger-section .logout__btn:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.swagger-section .auth_container .basic_auth__title {
|
||||
color: #547f00;
|
||||
font-size: 1.2em;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
SwaggerUi.Views.AuthView = Backbone.View.extend({
|
||||
events: {
|
||||
'click .authorize__btn': 'authorizeBtnClick',
|
||||
'click .logout__btn' : 'logoutClick'
|
||||
'click .authorize__btn': 'authorizeBtnClick'
|
||||
},
|
||||
|
||||
tpls: {
|
||||
@@ -36,61 +35,30 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
|
||||
},
|
||||
|
||||
renderAuths: function (auths) {
|
||||
var name, authEl, auth;
|
||||
var name, authEl, authModel;
|
||||
var el = $('<div>');
|
||||
var authz = window.swaggerUi.api.clientAuthorizations.authz;
|
||||
|
||||
//todo refactor, copy-pasted from MainView.js
|
||||
for (name in auths) {
|
||||
auth = auths[name];
|
||||
authModel = _.extend({}, auths[name]);
|
||||
|
||||
if (auth.type === 'apiKey') {
|
||||
authEl = new SwaggerUi.Views.ApiKeyButton({model: auth, router: this.router}).render().el;
|
||||
if (authz[name]) {
|
||||
_.extend(authModel, {
|
||||
isLogout: true,
|
||||
value: authz[name].value
|
||||
});
|
||||
}
|
||||
|
||||
if (authModel.type === 'apiKey') {
|
||||
authEl = new SwaggerUi.Views.ApiKeyButton({model: authModel, router: this.router}).render().el;
|
||||
el.append(authEl);
|
||||
} else if (auth.type === 'basic' && el.find('.basic_auth_container').length === 0) {
|
||||
authEl = new SwaggerUi.Views.BasicAuthButton({model: auth, router: this.router}).render().el;
|
||||
} else if (authModel.type === 'basic' && el.find('.basic_auth_container').length === 0) {
|
||||
authEl = new SwaggerUi.Views.BasicAuthButton({model: authModel, router: this.router}).render().el;
|
||||
el.append(authEl);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
logoutClick: function (e) {
|
||||
var authsModel;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
authsModel = {
|
||||
title: 'Logout authorizations',
|
||||
content: this.renderAuths(this.getAuthMap())
|
||||
};
|
||||
|
||||
this.popup = new SwaggerUi.Views.PopupView({model: authsModel});
|
||||
this.popup.render();
|
||||
},
|
||||
|
||||
getAuthMap: function () {
|
||||
var authsMap = {};
|
||||
|
||||
_.forEach(window.swaggerUi.api.clientAuthorizations.authz, function (value, key) {
|
||||
if (key === 'basic') {
|
||||
authsMap.basic = {
|
||||
type: key,
|
||||
isLogout: true,
|
||||
name: key
|
||||
};
|
||||
} else {
|
||||
authsMap[key] = {
|
||||
type: 'apiKey',
|
||||
'in': value.type,
|
||||
value: value.value,
|
||||
isLogout: true,
|
||||
name: key
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return authsMap;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({
|
||||
event.preventDefault();
|
||||
var username = this.$('.basic_auth__username').val();
|
||||
var password = this.$('.basic_auth__password').val();
|
||||
var basicAuth = new SwaggerClient.PasswordAuthorization('basic', username, password);
|
||||
var basicAuth = new SwaggerClient.PasswordAuthorization(username, password);
|
||||
this.router.api.clientAuthorizations.add(this.model.type, basicAuth);
|
||||
this.router.load();
|
||||
},
|
||||
|
||||
@@ -30,14 +30,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.logout__btn {
|
||||
padding-left: 15px;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.auth_container {
|
||||
|
||||
.basic_auth__title {
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
<a class='authorize__btn'>Click to Authorize</a>
|
||||
{{#if isLogout}}
|
||||
<a class='logout__btn'>Log out</a>
|
||||
{{/if}}
|
||||
<a class='authorize__btn'>Click to Authorize{{#if isLogout}}/Logout {{/if}}</a>
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class='container' id='resources_container'>
|
||||
<div class="auth_main_container"></div>
|
||||
|
||||
<div class='authorize-wrapper'></div>
|
||||
|
||||
<ul id='resources'></ul>
|
||||
|
||||
Reference in New Issue
Block a user