HTTP Auth fixes

This commit is contained in:
varjolintu 2018-04-14 09:05:06 +03:00
parent a01109e345
commit efec41cb20
6 changed files with 60 additions and 57 deletions

View file

@ -85,7 +85,7 @@ httpAuth.loginOrShowCredentials = function(logins, details, resolve, reject) {
});
} else {
if (page.settings.showNotifications) {
showNotification('Multiple credentials detected. Click on the extension icon to choose the correct one.');
showNotification('HTTP authentication with multiple credentials detected. Click on the extension icon to choose the correct one.');
}
kpxcEvent.onHTTPAuthPopup(null, { 'id': details.tabId }, { 'logins': logins, 'url': details.searchUrl, 'resolve': resolve });
}

View file

@ -7,33 +7,15 @@ body {
font-size: 15px;
padding: 8px;
}
.credentials ul {
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
list-style-position: inside;
.list-group {
font-size: .9em !important;
}
.credentials li {
list-style: none;
padding-top: 1px;
padding-bottom: 1px;
padding-left: 5px;
padding-right: 5px;
margin-left: 10px;
margin-right: 5px;
.list-group-item {
padding: 5px 10px !important;
}
.credentials a {
color: #333;
}
.credentials a:hover {
text-decoration: none;
}
.credentials li:hover {
.list-group-item:hover {
cursor: pointer;
background: #ddd;
}
.settings {
padding-bottom: 10px;
margin-bottom: 10px;

View file

@ -29,7 +29,10 @@
<p>
Select the login information you would like to get logged in with:
</p>
<ul id="login-list"></ul>
<div id="login-list" class="list-group"></div>
<p>
<button id="btn-dismiss" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-remove"></span> Dismiss and show the default authentication dialog</button>
</p>
</div>
</div>
</body>

View file

@ -1,37 +1,57 @@
'use strict';
$(function() {
browser.runtime.getBackgroundPage().then((global) => {
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
let tab = tabs[0];
const data = global.page.tabs[tab.id].loginList;
let ul = document.getElementById('login-list');
for (let i = 0; i < data.logins.length; i++) {
const li = document.createElement('li');
const a = document.createElement('a');
a.textContent = data.logins[i].login + " (" + data.logins[i].name + ")";
li.appendChild(a);
$(a).data('creds', data.logins[i]);
$(a).click(function () {
if (data.resolve) {
const creds = $(this).data('creds');
data.resolve({
authCredentials: {
username: creds.login,
password: creds.password
}
});
}
close();
});
ul.appendChild(li);
}
const getLoginData = function() {
return new Promise((resolve, reject) => {
browser.runtime.getBackgroundPage().then((global) => {
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
resolve(global.page.tabs[tabs[0].id].loginList);
});
});
});
};
$(function() {
getLoginData().then((data) => {
let ll = document.getElementById('login-list');
for (let i = 0; i < data.logins.length; ++i) {
const a = document.createElement('a');
a.setAttribute('class', 'list-group-item');
a.textContent = data.logins[i].login + " (" + data.logins[i].name + ")";
$(a).data('creds', data.logins[i]);
$(a).click(function () {
if (data.resolve) {
const creds = $(this).data('creds');
data.resolve({
authCredentials: {
username: creds.login,
password: creds.password
}
});
}
close();
});
ll.appendChild(a);
}
});
$('#lock-database-button').click(function() {
browser.runtime.sendMessage({
action: 'lock-database'
}).then(status_response);
});
$('#btn-dismiss').click(function() {
getLoginData().then((data) => {
// Using reject won't work with every browser. So return empty credentials instead.
if (data.resolve) {
data.resolve({
authCredentials: {
username: '',
password: ''
}
});
}
close();
});
});
});

View file

@ -29,7 +29,7 @@
<p>
Select the login information you would like to get entered into the page:
</p>
<ul id="login-list"></ul>
<div id="login-list" class="list-group"></div>
</div>
</div>
</body>

View file

@ -9,13 +9,11 @@ $(function() {
const tab = tabs[0];
const logins = global.page.tabs[tab.id].loginList;
let ul = document.getElementById('login-list');
let ll = document.getElementById('login-list');
for (let i = 0; i < logins.length; i++) {
const li = document.createElement('li');
const a = document.createElement('a');
a.textContent = logins[i];
li.setAttribute('class', 'list-group-item');
li.appendChild(a);
a.setAttribute('class', 'list-group-item');
a.setAttribute('id', '' + i);
a.addEventListener('click', (e) => {
const id = e.target.id;
@ -25,7 +23,7 @@ $(function() {
});
close();
});
ul.appendChild(li);
ll.appendChild(a);
}
});
});