lighthouse score
This commit is contained in:
parent
0cad501405
commit
4309d65c85
|
@ -44,16 +44,16 @@ async def index(request):
|
||||||
"SELECT * FROM user_credential WHERE user_id = $1",
|
"SELECT * FROM user_credential WHERE user_id = $1",
|
||||||
request['session']['id'])
|
request['session']['id'])
|
||||||
active_sessions = await conn.fetch(
|
active_sessions = await conn.fetch(
|
||||||
"SELECT ip_address FROM user_session "
|
"SELECT id, ip_address FROM user_session "
|
||||||
"WHERE user_id = $1",
|
"WHERE user_id = $1",
|
||||||
request['session']['id'])
|
request['session']['id'])
|
||||||
|
|
||||||
if request['session']['admin']:
|
if request['session']['admin']:
|
||||||
users = defaultdict(lambda: [False]*len(apps))
|
users = defaultdict(lambda: {app['name']: False for app in apps})
|
||||||
for user_perm in user_perms:
|
for user_perm in user_perms:
|
||||||
index = tools.find_dict(apps, 'id', user_perm['app_id'])
|
index = tools.find_dict(apps, 'id', user_perm['app_id'])
|
||||||
if index != -1:
|
if index != -1:
|
||||||
users[user_perm['username']][index] = True
|
users[user_perm['username']][apps[index]['name']] = True
|
||||||
users_json = json.dumps(users)
|
users_json = json.dumps(users)
|
||||||
return render_template("index.html", request, locals())
|
return render_template("index.html", request, locals())
|
||||||
|
|
||||||
|
|
|
@ -14,19 +14,19 @@ function load() {
|
||||||
|
|
||||||
function perm_change(row) {
|
function perm_change(row) {
|
||||||
let user_perms = users_perms[row.children[0].textContent];
|
let user_perms = users_perms[row.children[0].textContent];
|
||||||
let row_perms = [];
|
let row_perms = {};
|
||||||
for (let child of row.children) {
|
for (let child of row.children) {
|
||||||
if (child.firstChild.type == "checkbox") {
|
if (child.firstChild.type == "checkbox") {
|
||||||
if (child.firstChild.checked) {
|
if (child.firstChild.checked) {
|
||||||
row_perms.push(true);
|
row_perms[child.firstChild.dataset.appName] = true;
|
||||||
} else {
|
} else {
|
||||||
row_perms.push(false);
|
row_perms[child.firstChild.dataset.appName] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let perms_changed = false;
|
let perms_changed = false;
|
||||||
for (let i = 0; i < user_perms.length; i++) {
|
for (let app_name of Object.keys(user_perms)) {
|
||||||
if (user_perms[i] != row_perms[i]) {
|
if (user_perms[app_name] != row_perms[app_name]) {
|
||||||
perms_changed = true;
|
perms_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@
|
||||||
{% for username, values in users.items() %}
|
{% for username, values in users.items() %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ username }}</td>
|
<td>{{ username }}</td>
|
||||||
{% for value in values %}
|
{% for name, value in values.items() %}
|
||||||
<td><input type="checkbox" onchange="perm_change(this.parentElement.parentElement)"{% if value %} checked{% endif %}></td>
|
<td><input aria-label="{{ username }}-{{ name }}" data-app-name={{ name }} type="checkbox" onchange="perm_change(this.parentElement.parentElement)"{% if value %} checked{% endif %}></td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<td><input type="submit"></td>
|
<td><input type="submit"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
{% for key in fido2_keys %}
|
{% for key in fido2_keys %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ key['nick'] }}</td>
|
<td>{{ key['nick'] }}</td>
|
||||||
<td><input type="checkbox"></td>
|
<td><input aria-label="Delete {{ key['nick'] }}" id="fido-{{ key['id'] }}" name="fido-{{ key['id'] }}" type="checkbox"></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
{% for session in active_sessions %}
|
{% for session in active_sessions %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ session['ip_address'] }}</td>
|
<td>{{ session['ip_address'] }}</td>
|
||||||
<td><input type="checkbox"></td>
|
<td><input aria-label="Delete {{ session['id'][:5] }}" id="session-{{ session['id'][:5] }}" name="session-{{ session['id'][:5] }}" type="checkbox"></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user