2022-06-29 11:28:26 +02:00
|
|
|
|
{% extends "default.html" %}
|
2019-11-28 23:14:55 +01:00
|
|
|
|
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{% block title %}API Key{% endblock %}
|
2019-12-29 10:56:27 +01:00
|
|
|
|
{% set active_page = "api_key" %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{% block head %}{% endblock %}
|
2019-11-28 23:14:55 +01:00
|
|
|
|
{% block default_content %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2019-11-28 23:14:55 +01:00
|
|
|
|
<div class="row">
|
2020-04-05 19:59:48 +02:00
|
|
|
|
<div class="col">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<h1 class="h3">API Keys</h1>
|
2022-06-08 10:31:58 +02:00
|
|
|
|
<div class="alert alert-info">
|
|
|
|
|
When you log in on a SimpleLogin mobile app or browser extension,
|
|
|
|
|
a new API Key is automatically created and stored on your device.
|
|
|
|
|
It's usually named after the device where it was created, e.g. Samsung S8, John's iPhone, etc.
|
2021-05-05 18:51:15 +02:00
|
|
|
|
</div>
|
|
|
|
|
<div class="alert alert-danger">
|
|
|
|
|
️API Keys should be kept secret and treated like passwords, they can be used to gain access to your account.
|
2020-01-20 11:16:04 +01:00
|
|
|
|
</div>
|
2020-05-03 10:48:21 +02:00
|
|
|
|
<div class="row">
|
|
|
|
|
{% for api_key in api_keys %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2020-05-03 10:48:21 +02:00
|
|
|
|
<div class="col-12 col-lg-6">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
2021-09-21 11:26:05 +02:00
|
|
|
|
<h5 class="card-title">{{ api_key.name or "N/A" }}</h5>
|
2020-05-03 10:48:21 +02:00
|
|
|
|
<h6 class="card-subtitle mb-2 text-muted">
|
|
|
|
|
{% if api_key.last_used %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2022-06-08 10:31:58 +02:00
|
|
|
|
Created {{ api_key.created_at | dt }}.
|
|
|
|
|
Used {{ api_key.times }} times.
|
|
|
|
|
Was last used {{ api_key.last_used | dt }}.
|
2020-05-03 10:48:21 +02:00
|
|
|
|
{% else %}
|
|
|
|
|
Never used
|
|
|
|
|
{% endif %}
|
|
|
|
|
</h6>
|
|
|
|
|
<div class="input-group">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<input class="form-control"
|
|
|
|
|
id="apikey-{{ api_key.id }}"
|
|
|
|
|
readonly
|
|
|
|
|
value="**********">
|
2020-05-03 10:48:21 +02:00
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<br />
|
2020-05-03 10:48:21 +02:00
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col">
|
|
|
|
|
<form method="post">
|
2023-01-12 12:34:47 +01:00
|
|
|
|
{{ csrf_form.csrf_token }}
|
2020-05-03 10:48:21 +02:00
|
|
|
|
<input type="hidden" name="form-name" value="delete">
|
|
|
|
|
<input type="hidden" name="api-key-id" value="{{ api_key.id }}">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<span class="card-link btn btn-link float-right text-danger delete-api-key">Delete</span>
|
2020-05-03 10:48:21 +02:00
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-11-28 23:14:55 +01:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-05-03 10:48:21 +02:00
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
2022-01-25 19:36:13 +01:00
|
|
|
|
{% if api_keys|length > 0 %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2022-01-25 19:36:13 +01:00
|
|
|
|
<form method="post">
|
2023-01-12 12:34:47 +01:00
|
|
|
|
{{ csrf_form.csrf_token }}
|
2022-01-25 19:36:13 +01:00
|
|
|
|
<input type="hidden" name="form-name" value="delete-all">
|
2022-06-08 10:31:58 +02:00
|
|
|
|
<span class="delete btn btn-outline-danger delete-all-api-keys float-right">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
Delete All <i class="fe fe-trash"></i>
|
2022-01-25 19:36:13 +01:00
|
|
|
|
</span>
|
|
|
|
|
</form>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<br />
|
2022-01-25 19:36:13 +01:00
|
|
|
|
{% endif %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<hr />
|
2019-11-28 23:14:55 +01:00
|
|
|
|
<form method="post">
|
2023-01-12 12:34:47 +01:00
|
|
|
|
{{ csrf_form.csrf_token }}
|
2019-11-28 23:14:55 +01:00
|
|
|
|
<input type="hidden" name="form-name" value="create">
|
2020-05-27 19:23:33 +02:00
|
|
|
|
<h2 class="h4">New API Key</h2>
|
|
|
|
|
{{ new_api_key_form.name(class="form-control", placeholder="Chrome") }}
|
2019-11-28 23:14:55 +01:00
|
|
|
|
{{ render_field_errors(new_api_key_form.name) }}
|
2020-05-03 10:48:21 +02:00
|
|
|
|
<div class="small-text">Name of the api key, e.g. where it will be used.</div>
|
2021-05-05 18:51:15 +02:00
|
|
|
|
<button class="btn btn-success mt-2">Create</button>
|
2019-11-28 23:14:55 +01:00
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{% endblock %}
|
|
|
|
|
{% block script %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2019-11-28 23:14:55 +01:00
|
|
|
|
<script>
|
|
|
|
|
$(".delete-api-key").on("click", function (e) {
|
2020-04-30 22:37:39 +02:00
|
|
|
|
let that = $(this);
|
|
|
|
|
|
|
|
|
|
bootbox.confirm({
|
2022-06-08 10:31:58 +02:00
|
|
|
|
message: "If this API Key is currently in use, you might need to login again on the corresponding device, please confirm.",
|
2020-04-30 22:37:39 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
|
|
|
|
label: 'Yes, delete it',
|
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: 'Cancel',
|
|
|
|
|
className: 'btn-outline-primary'
|
|
|
|
|
}
|
2019-11-28 23:14:55 +01:00
|
|
|
|
},
|
2020-04-30 22:37:39 +02:00
|
|
|
|
callback: function (result) {
|
|
|
|
|
if (result) {
|
|
|
|
|
that.closest("form").submit();
|
|
|
|
|
}
|
2019-11-28 23:14:55 +01:00
|
|
|
|
}
|
2020-04-30 22:37:39 +02:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
2022-01-23 19:38:54 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(".delete-all-api-keys").on("click", function (e) {
|
2022-06-08 10:31:58 +02:00
|
|
|
|
let that = $(this);
|
2022-01-23 19:38:54 +01:00
|
|
|
|
|
2022-06-08 10:31:58 +02:00
|
|
|
|
bootbox.confirm({
|
|
|
|
|
message: "This will delete all API Keys, they will all stop working, are you sure?",
|
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
|
|
|
|
label: 'Delete All',
|
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: 'Cancel',
|
|
|
|
|
className: 'btn-outline-primary'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
callback: function (result) {
|
|
|
|
|
if (result) {
|
|
|
|
|
that.closest("form").submit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2020-02-19 17:45:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
2022-06-08 10:31:58 +02:00
|
|
|
|
|
2019-11-28 23:14:55 +01:00
|
|
|
|
</script>
|
2020-05-27 19:23:33 +02:00
|
|
|
|
{% endblock %}
|