summaryrefslogtreecommitdiff
path: root/src/invidious/views/user/login.ecr
blob: 01d7a21003573e4a28ed1c5896ab86469c061b4a (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<% content_for "header" do %>
<title><%= translate(locale, "Log in") %> - Invidious</title>
<% end %>

<div class="pure-g">
    <div class="pure-u-1 pure-u-lg-1-5"></div>
    <div class="pure-u-1 pure-u-lg-3-5">
        <div class="h-box">
            <% case account_type when %>
            <% when "google" %>
                <form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.encode_www_form(referer) %>&type=google" method="post">
                    <fieldset>
                        <% if email %>
                            <input name="email" type="hidden" value="<%= HTML.escape(email) %>">
                        <% else %>
                            <label for="email"><%= translate(locale, "E-mail") %> :</label>
                            <input required class="pure-input-1" name="email" type="email" placeholder="<%= translate(locale, "E-mail") %>">
                        <% end %>

                        <% if password %>
                            <input name="password" type="hidden" value="<%= HTML.escape(password) %>">
                        <% else %>
                            <label for="password"><%= translate(locale, "Password") %> :</label>
                            <input required class="pure-input-1" name="password" type="password" placeholder="<%= translate(locale, "Password") %>">
                        <% end %>

                        <% if prompt %>
                            <label for="tfa"><%= translate(locale, prompt) %> :</label>
                            <input required class="pure-input-1" name="tfa" type="text" placeholder="<%= translate(locale, prompt) %>">
                        <% end %>

                        <% if tfa %>
                            <input type="hidden" name="tfa" value="<%= tfa %>">
                        <% end %>

                        <% if captcha %>
                            <img style="width:50%" src="/Captcha?v=2&ctoken=<%= captcha[:tokens][0] %>"/>
                            <input type="hidden" name="token" value="<%= captcha[:tokens][0] %>">
                            <label for="answer"><%= translate(locale, "Answer") %> :</label>
                            <input type="text" name="answer" type="text" placeholder="<%= translate(locale, "Answer") %>">
                        <% end %>

                        <button type="submit" class="pure-button pure-button-primary"><%= translate(locale, "Sign In") %></button>
                    </fieldset>
                </form>
            <% else # "invidious" %>
                <form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.encode_www_form(referer) %>&type=invidious" method="post">
                    <fieldset>
                        <% if email %>
                            <input name="email" type="hidden" value="<%= HTML.escape(email) %>">
                        <% else %>
                            <label for="email"><%= translate(locale, "User ID") %> :</label>
                            <input required class="pure-input-1" name="email" type="text" placeholder="<%= translate(locale, "User ID") %>">
                        <% end %>

                        <% if password %>
                            <input name="password" type="hidden" value="<%= HTML.escape(password) %>">
                        <% else %>
                            <label for="password"><%= translate(locale, "Password") %> :</label>
                            <input required class="pure-input-1" name="password" type="password" placeholder="<%= translate(locale, "Password") %>">
                        <% end %>

                        <% if captcha %>
                            <% case captcha_type when %>
                            <% when "image" %>
                                <% captcha = captcha.not_nil! %>
                                <img style="width:50%" src='<%= captcha[:question] %>'/>
                                <% captcha[:tokens].each_with_index do |token, i| %>
                                    <input type="hidden" name="token[<%= i %>]" value="<%= HTML.escape(token) %>">
                                <% end %>
                                <input type="hidden" name="captcha_type" value="image">
                                <label for="answer"><%= translate(locale, "Time (h:mm:ss):") %></label>
                                <input type="text" name="answer" type="text" placeholder="h:mm:ss">
                            <% else # "text" %>
                                <% captcha = captcha.not_nil! %>
                                <% captcha[:tokens].each_with_index do |token, i| %>
                                    <input type="hidden" name="token[<%= i %>]" value="<%= HTML.escape(token) %>">
                                <% end %>
                                <input type="hidden" name="captcha_type" value="text">
                                <label for="answer"><%= captcha[:question] %></label>
                                <input type="text" name="answer" type="text" placeholder="<%= translate(locale, "Answer") %>">
                            <% end %>

                            <button type="submit" name="action" value="signin" class="pure-button pure-button-primary">
                                <%= translate(locale, "Register") %>
                            </button>

                            <% case captcha_type when %>
                            <% when "image" %>
                                <label>
                                    <button type="submit" name="change_type" class="pure-button pure-button-primary" value="text">
                                        <%= translate(locale, "Text CAPTCHA") %>
                                    </button>
                                </label>
                            <% else # "text" %>
                                <label>
                                    <button type="submit" name="change_type" class="pure-button pure-button-primary" value="image">
                                        <%= translate(locale, "Image CAPTCHA") %>
                                    </button>
                                </label>
                            <% end %>
                        <% else %>
                            <button type="submit" name="action" value="signin" class="pure-button pure-button-primary">
                                <%= translate(locale, "Sign In") %>/<%= translate(locale, "Register") %>
                            </button>
                        <% end %>
                    </fieldset>
                </form>
            <% end %>
        </div>
    </div>
    <div class="pure-u-1 pure-u-lg-1-5"></div>
</div>