summaryrefslogtreecommitdiff
path: root/src/invidious/views/user/authorize_token.ecr
blob: 725f392ed6b17a6d27a6a0d8c8f55ebfa332fba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<% content_for "header" do %>
<title><%= translate(locale, "Token") %> - Invidious</title>
<% end %>

<% if env.get? "access_token" %>
    <div class="pure-g h-box">
        <div class="pure-u-1-3">
            <h3>
                <%= translate(locale, "Token") %>
            </h3>
        </div>
        <div class="pure-u-1-3">
            <h3 style="text-align:center">
                <a href="/token_manager"><%= translate(locale, "Token manager") %></a>
            </h3>
        </div>
        <div class="pure-u-1-3">
            <h3 style="text-align:right">
                <a href="/preferences"><%= translate(locale, "Preferences") %></a>
            </h3>
        </div>
    </div>

    <div class="h-box">
        <h4 style="padding-left:0.5em">
            <code><%= env.get "access_token" %></code>
        </h4>
    </div>
<% else %>
    <div class="h-box">
        <form class="pure-form pure-form-aligned" action="/authorize_token" method="post">
            <% if callback_url %>
                <legend><%= translate(locale, "Authorize token for `x`?", "#{callback_url.scheme}://#{callback_url.host}")  %></legend>
            <% else %>
                <legend><%= translate(locale, "Authorize token?") %></legend>
            <% end %>

            <div class="pure-g">
                <div class="pure-u-1">
                    <ul>
                        <% scopes.each do |scope| %>
                            <li><%= HTML.escape(scope) %></li>
                        <% end %>
                    </ul>
                </div>
            </div>

            <div class="pure-g">
                <div class="pure-u-1-2">
                    <button type="submit" name="submit" value="clear_watch_history" class="pure-button pure-button-primary">
                        <%= translate(locale, "Yes") %>
                    </button>
                </div>
                <div class="pure-u-1-2">
                    <% if callback_url %>
                        <a class="pure-button" href="<%= callback_url %>">
                    <% else %>
                        <a class="pure-button" href="/">
                    <% end %>
                    <%= translate(locale, "No") %>
                    </a>
                </div>
            </div>

            <% scopes.each_with_index do |scope, i| %>
                <input type="hidden" name="scopes[<%= i %>]" value="<%= scope %>">
            <% end %>
            <% if callback_url %>
                <input type="hidden" name="callbackUrl" value="<%= callback_url %>">
            <% end %>
            <% if expire %>
                <input type="hidden" name="expire" value="<%= expire %>">
            <% end %>

            <input type="hidden" name="csrf_token" value="<%= HTML.escape(csrf_token) %>">
        </form>
    </div>
<% end %>