2019-04-18 21:23:50 +00:00
|
|
|
<% content_for "header" do %>
|
|
|
|
<title><%= translate(locale, "Token manager") %> - Invidious</title>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<div class="pure-g h-box">
|
|
|
|
<div class="pure-u-1-3">
|
|
|
|
<h3>
|
|
|
|
<%= translate(locale, "`x` tokens", %(<span id="count">#{tokens.size}</span>)) %>
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
<div class="pure-u-1-3"></div>
|
|
|
|
<div class="pure-u-1-3" style="text-align:right">
|
|
|
|
<h3>
|
2019-05-03 17:15:21 +00:00
|
|
|
<a href="/preferences?referer=<%= URI.escape(referer) %>"><%= translate(locale, "Preferences") %></a>
|
2019-04-18 21:23:50 +00:00
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<% tokens.each do |token| %>
|
|
|
|
<div class="h-box">
|
|
|
|
<div class="pure-g<% if token[:session] == sid %> deleted <% end %>">
|
|
|
|
<div class="pure-u-3-5">
|
|
|
|
<h4 style="padding-left:0.5em">
|
|
|
|
<code><%= token[:session] %></code>
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div class="pure-u-1-5" style="text-align:center">
|
|
|
|
<h4><%= translate(locale, "`x` ago", recode_date(token[:issued], locale)) %></h4>
|
|
|
|
</div>
|
|
|
|
<div class="pure-u-1-5" style="text-align:right">
|
|
|
|
<h3 style="padding-right:0.5em">
|
|
|
|
<form onsubmit="return false" action="/token_ajax?action_revoke_token=1&session=<%= token[:session] %>&referer=<%= env.get("current_page") %>" method="post">
|
|
|
|
<input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>">
|
|
|
|
<a onclick="revoke_token(this)" data-session="<%= token[:session] %>" href="#">
|
|
|
|
<input style="all:unset" type="submit" value="<%= translate(locale, "revoke") %>">
|
|
|
|
</a>
|
|
|
|
</form>
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<% if tokens[-1].try &.[:session]? != token[:session] %>
|
2019-05-02 01:03:39 +00:00
|
|
|
<hr>
|
2019-04-18 21:23:50 +00:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function revoke_token(target) {
|
|
|
|
var row = target.parentNode.parentNode.parentNode.parentNode.parentNode;
|
2019-05-02 01:03:39 +00:00
|
|
|
row.style.display = 'none';
|
|
|
|
var count = document.getElementById('count');
|
2019-04-18 21:23:50 +00:00
|
|
|
count.innerText = count.innerText - 1;
|
|
|
|
|
2019-05-02 01:03:39 +00:00
|
|
|
var url = '/token_ajax?action_revoke_token=1&redirect=false' +
|
|
|
|
'&referer=<%= env.get("current_page") %>' +
|
|
|
|
'&session=' + target.getAttribute('data-session');
|
2019-04-18 21:23:50 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
2019-05-02 01:03:39 +00:00
|
|
|
xhr.responseType = 'json';
|
2019-04-18 21:23:50 +00:00
|
|
|
xhr.timeout = 20000;
|
2019-05-02 01:03:39 +00:00
|
|
|
xhr.open('POST', url, true);
|
|
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
2019-04-18 21:23:50 +00:00
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.status != 200) {
|
2019-05-02 01:03:39 +00:00
|
|
|
count.innerText = parseInt(count.innerText) + 1;
|
|
|
|
row.style.display = '';
|
2019-04-18 21:23:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-15 15:08:06 +00:00
|
|
|
|
|
|
|
xhr.send('csrf_token=<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>');
|
2019-04-18 21:23:50 +00:00
|
|
|
}
|
2019-05-02 01:03:39 +00:00
|
|
|
</script>
|